getSelection() by Double Click or manual selection is not the same
Posted
by sanceray3
on Stack Overflow
See other posts from Stack Overflow
or by sanceray3
Published on 2010-03-24T22:26:59Z
Indexed on
2010/03/24
22:33 UTC
Read the original article
Hit count: 320
getselection
|double-click
Hi all,
I allow me to ask a question, because I have a little probleme with an function which returns me the parent of a selection.
$('input[type=button].btn_transform').click(function(){
var selectionObj = getSelected();//Function which gives me selection
var theParent=selectionObj.anchorNode.parentNode;
alert (theParent);
})
For example with this sentence : "the cat is <strong>
gray</strong>
."
If I select manually the word "gray" and click on my button, the function returns me [object HTMLSpanElement].
But if I select the same word by double clicking, the function returns me [object HTMLParagraphElement].
Do you know why ?
Thanks a lot.
© Stack Overflow or respective owner