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