Skip to content
Advertisement

Tag: getselection

React table cell getSelection()

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

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

Advertisement