jquery - Double click word JavaScript window.getSelection in two INS tag -


my html is:

<p><ins data-id="1">111</ins><ins data-id="2">222</ins></p> 

the output of code is:

enter image description here

if double click word, it's selecting complete word, this:

enter image description here

but want select letters based on ins tag data-id

ex:- if double click 111 want select 111 this:

enter image description here

how modify default double click selection javascript selection?

i tried following code:

var containerid = $(e.currenttarget); if (window.getselection) {    var range = document.createrange();    range.selectnode(containerid);    var sel = window.getselection()    sel.removeallranges();    sel.addrange(range); } 

but it's not working expected.

<p><ins data-id="1">111</ins>&#8203;<ins data-id="2">222</ins></p>

you put zero-width space between them: &#8203;


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -