jQuery > Selectors

:last-child - Last child selector in jQuery

How to select last child of the parent element in jQuery?


To select the last child of the parent element, last child selector can be used. 

<script language="javascript" type="text/javascript">
$("#div2 p:last-child").css("background", "red");
</script>

Above code snippet will select the last paragraph (p) element that is inside the div element whose id is “div2” and will change the background color as red. 

 Views: 7192 | Post Order: 16



Write for us






Hosting Recommendations