Using jQuery, what is the most efficient way to find the first two children of a parent if one is h1 and the other is p . My code is not working right now, and I would like to do it using best practices.
CSS
div > *{ display: none; }
HTML
<div> <h1>Heading</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> </div> <div> <h1>Heading</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> </div>
Javascript
$('div h1').show(); $('div p:first-child').show();
Edit I work with several divs. I did not think that it would matter, but it looks like I was wrong.
colindunn
source share