vendredi 20 février 2015

How can you get the dom element the caret is in?


I'm looking for a robust way to find where the active caret on the page is. I've learned the following things (at least about chrome):



  • Every input and textarea has its own separate caret

  • Only one caret can be "active" on the page, meaning that if you press the arrow keys, only one of the carets will be affected

  • The active caret does not have to be inside the element document.activeElement (e.g. if you use inputDomNode.setSelectionRange, whatever element that was previously focused remained in focus).


So I'm basically wondering how to figure out which caret will move when you press an arrow key.





Aucun commentaire:

Enregistrer un commentaire