I have a string like below.
<div data-sentence="1"><p>authorised representative (No. 45678) of</p></div>
<div data-sentence="2"><p>you have asked for my advice</p></div>
When user select(drawing) the string like '45678', I can get the the selected text by the function funGetSelectTxt below. My question is how can I get this element's parent div and return back the value of attribute 'data-sentence'?
function funGetSelectTxt() {
var element = '';
if (document.selection) {
element = document.selection.createRange().text;
} else {
element = document.getSelection();
}
return $.trim(element.toString());
}
Thanks,