I’m trying to match the h4 of a div (using jQuery) so that I can remove it’s top margin. However, I only want to match the h4 if it has no text on top of it. For example, match this:
<div> <h4>Header</h4> ... </div>
but not this:
<div> Blah blah blah. <h4>Header</h4> ... </div>
The best code I could come up with in jQuery is this:
$('div h4:first-child')
But that, unfortunately, matches both the above cases. Is there anyway to specify that you want it to be the absolute first element, with no text nodes before it?
then you could use the following.