Skip to content Skip to sidebar Skip to footer

Find Selectedtext By Mouse Selection In Div Jquery?

I want to find it out selected text on div which select by mouse. I found out .select() method for select. but its not accomplish my problem. i want to something like :

Solution 1:

you don't need to select it. all you need to do is to add a click handler.

document.addEventListener('touchend', handleTouchEnd, false);
function handleTouchEnd(e){
   console.log(e.target.innerHTML);// returns whatever is there in the div
   console.log(e.target.textContent);// better option, as it returns text only
}

Post a Comment for "Find Selectedtext By Mouse Selection In Div Jquery?"