How i can get parent object of this anchor via javaScript ?
<p>Lorem Ipsum is simply dummy
text of the printing and typesetting
<a href="http://somplace.com/index.php?content=
{{in this place i want to retrieve 20 character of
the parent p}}"></a> industry.
</p>
Use
this.parentNode.innerHTML.substring(0, 20):Here:
thisrefers to current linkparentNoderefers to parent of link eg paragraph in this caseinnerHTMLto read parent’s htmlsubstringused to get chars from 0 to 20 in this case.Working Example