jQuery get id of last div inside a div

The correct way to get the id of the last child div inside parent container using jQuery:

<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>
$('#container').children().last().attr('id');

Or

var id = $('#container div:last').attr('id')

By Keenlio, April 8, 2014

One Comment

  1. jQuery get id of last div inside a div page says:

    I discovered your jQuery get id of last div inside a div page and noticed you could have a lot more visitors. I have found that the key to running a popular website is making sure the visitors you are getting are interested in your niche. There is a company that you can get traffic from and they let you try the service for free. I managed to get over 300 targeted visitors to day to my website.

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


3 − three =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>