1

I am working on a small function where you can enter HTML tags with text between them onclick. My problem is the code below doesn't quite work in IE8.

var textArea = $('.area').get(0);
var len = textArea.value.length;
textArea.selectionStart = len;
textArea.selectionEnd = len;
textArea.focus();

IE8 doesn't seem to take the length of the text into consideration and instead of positioning the cursor after the closing tag, it positions itself in front of the opening tag. So, for instance, if you enter: < b >SOME TEXT HERE< / b > onclick the cursor will jump back to the front.

Feel free to ask for any additional info.

VitalSigns
  • 87
  • 8
  • 1
    have a look at http://stackoverflow.com/a/263796/2375207 – nicolallias Oct 15 '15 at 12:51
  • @nicolallias You know I saw that one before. I tried to copy and paste it into my current function, but it didn't anything. I was doing something wrong I guess. How would you implement the code you cited with my current code above? – VitalSigns Oct 15 '15 at 12:58

0 Answers0