let range = window.getSelection().getRangeAt(0);
parObj = getContainingP(range.commonAncestorContainer);
return alert(parObj ? parObj.id : 'null' );
function getContainingP(node) {
while (node) {
if (node.nodeType == 1 && node.tagName.toLowerCase() == "p") {
return node;
}
node = node.parentNode;
}
}