I have a div
that have multiple p
tags. I want to get the text of the p
element that is not empty. For example
<div>
<p></p>
<p></p>
<p>data</p>
<span>some</span>
</div>
I want to get data of third p
element that is data
.
I can use
document.querySelector("p:nth-child(1)");
but in above case I have to define the child no. But how can I get the p based on empty condition