After highlighting text, I would like to obtain the paragraph in which the selected text resides.
var select = window._content.document.getSelection();
Any pointers please?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is actually rather hard to do because you have to consider six cases:
So firstly you have to decide how complete you want the solution to be. I’ll only cover the simplest cases of (1) and (2).
Note: If you’re after tags too replace textContent with innerHTML.
Edit: Better version put in, including better browser compatibility.