¡@

Home 

2014/10/16 ¤W¤È 12:05:03

jquery Programming Glossary: markerel

How can I position an element next to user text selection?

http://stackoverflow.com/questions/1589721/how-can-i-position-an-element-next-to-user-text-selection

markerTextChar ufeff var markerTextCharEntity #xfeff var markerEl markerId sel_ new Date .getTime _ Math.random .toString .substr.. ' style position relative ' markerTextCharEntity ' span ' markerEl document.getElementById markerId else if window.getSelection.. single invisible character using DOM methods and insert it markerEl document.createElement span markerEl.id markerId markerEl.appendChild..

How can I position an element next to user text selection?

http://stackoverflow.com/questions/1589721/how-can-i-position-an-element-next-to-user-text-selection

should get you started var markSelection function var markerTextChar ufeff var markerTextCharEntity #xfeff var markerEl markerId sel_ new Date .getTime _ Math.random .toString .substr 2 var selectionEl return function var sel range if document.selection.. HTML and insert it range.pasteHTML ' span id ' markerId ' style position relative ' markerTextCharEntity ' span ' markerEl document.getElementById markerId else if window.getSelection sel window.getSelection if sel.getRangeAt range sel.getRangeAt.. false Create the marker element containing a single invisible character using DOM methods and insert it markerEl document.createElement span markerEl.id markerId markerEl.appendChild document.createTextNode markerTextChar range.insertNode..