To select first child of the parent element first child selector can be used.
<script language="javascript" type="text/javascript">
$("#div2 p:first-child").css("background", "red");
</script>
Above code snippet will select the first paragraph (p) element that is inside the div element having id as “div2” and will change the background color as red.
Views: 9584 | Post Order: 15