Reputation: 3558
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 :
<div id='mydiv'>Lorem Ipsum is simply dummy text of the printing.</div>
when i selected simply
text using mouse selection.i found it out using jquery
.
or something else another selected i want to get it.
Upvotes: 0
Views: 2545
Reputation: 872
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
}
Upvotes: 2