I have the below.
<div id=container>
<div id=box1></div>
<div id=box2></div>
<div id=box3></div>
<div id=box4></div>
<div id=box5></div>
<div id=box6></div>
</div>
What is the correct way to get the id of the last div inside container using jQuery?
You can try this:
jQuery Code
$(document).ready(function(){
$('#container').children().last().attr('id');
});
Try this:
var id = $('#container div:last').attr('id')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With