javascript - Customize typing cursor in string -
i wish change writing cursor (while typing there show/hide cursor) position in replace string.
here string:
if(str.indexof('<html>') != -1){ str = str.replace(/\<html\>([a-z|a-z|0-9| ])/g, "<html>\n \n</html>"); }
that means when typing <html>
result is:
<html> </html>| ^ typing cursor
now wanted result:
<html> | </html>
how can customize/place typing cursor in replacement string?
try in js console on stackoverflow, after clicking [ask question]:
document.queryselector('textarea#wmd-input').value = "here >< caret" document.queryselector('textarea#wmd-input').selectionstart = 6 document.queryselector('textarea#wmd-input').selectionend = 6
for element types other textarea
element.setselection(startposition, startposition)
might work.
Comments
Post a Comment