javascript - how to move the text in input using js -
i use js set text input's value. when text longer input can hold, excess text hidden in right part of input. how can hide excess text in left area normal typing? forgive poor english.
when perform caret position @ beginning of text. need move caret position end.
function setcursor(node,pos){ var node = (typeof node == "string" || node instanceof string) ? document.getelementbyid(node) : node; if (!node) { return false; } else if (node.createtextrange) { var textrange = node.createtextrange(); textrange.collapse(true); textrange.moveend(pos); textrange.movestart(pos); textrange.select(); return true; } else if (node.setselectionrange) { node.setselectionrange(pos,pos); return true; } return false; } setcursor(input, input.value.length); // input textbox
Comments
Post a Comment