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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -