Take a look at the snippet of code in an HTML page below--
<div id="div2"> Text2 </div>
Now, user selects only "Te" from the text shown in web page in browser...
How do I check if the user has selected entire content of div with id=div2?
I do understand how to get list of nodes corresponding to content selected by the user-- but in this case, since user has selected only "Te" --- only a single node is obtained - i.e. text node that contains text "Te"... Hence I am confused...
What is the easiest way to check if user selection comprises of an entire Div (or p for that matter)?
One more question is if user has selected content of multiple divs, then how do I check if each of those (multiple) divs' entire content has been selected?
For example take a look at HTML snippet below--
<div id="div1"> Text1 </div>
<div id="div2"> Text2 </div>
<div id="div3"> Text3 </div>
Here, user has selected text of all 3 divs above...
Finally, if user has selected content of multiple divs, all of which are within a single parent div, then how do I check if the user has selected entire content of that parent div, or only some content? The parent div may contain other divs, p elements, and images and links too...
I dont mind using pure js, or libraries like jquery for this purpose...