I have a table with an onRowClick handler on the <tr/> element, I want to prevent a click event if I select text inside it, my solution was this: What I found odd is, when I select a text inside a cell, and click on the same cell, the click event is not fired until the selection is cleared, but
Tag: getselection
Ignore span stag in window selection to get the start and end index
I have a html tag which is I am trying to get the start and end index from the selected text. When I select third I get start and end index as 34 39 But I expect 27 32 I tried the below approach Is there any way where I can ignore the span element with ignore class. Answer Store
window.getSelection().baseOffset is wrong
If you select any text below beginning at the first character H, it will say the baseOffset of the selection is 5. In my real-life case it says 7. How do I correct this? Answer The result is correct, you have exactly 5 space characters between the end of <div id=’main’data-alignment=”center”> and the H, these will be counted as offset.
Javascript selected text highlighting prob
I have a html page with text content. On selecting any text and pressing the highlight button, I can change the style of the selected text to highlight the same. To implement this feature, i have written the following method. This is working fine if you choose a text with no html tag, but when the text has any html