tags:

views:

44

answers:

3

Hello. I have this code :

<div class="content">       
    <div class="tlcontent"> 
        <div class="sideon" id="sideline0"> 
            somethings
        </div>

        <div class="trackon" id="trackline0">
            somethings
        </div>

        <div class="sideon" id="sideline1"> 
            somethings
        </div>

        <div class="trackon" id="trackline1">
            somethings
        </div>

        <div class="sideon" id="sideline2">
            somethings
        </div>
    </div>
</div>

How can select (with jquery) the latest element of this div with classname trackon? (in this case, the #trackline1) cheers

+1  A: 
$('.tlcontent').children().last()

If you just what the last thing in content, try:

$('.content :last')

Example: http://jsfiddle.net/Kgp2u/

Kobi
uhm great! but i forgot 1 question : if i need only the last children with class "trackon" ? :)
markzzz
@markzzz - In that case you can use `$('.content .trackon:last')`. jQuery selectors can be very powerful, I suggest you read a little on the subject, it can save you quite a few minutes of coding `:)`
Kobi
+3  A: 
var latest = $('.tlcontent div:last');
latest.css({color:'red'});

demo

Reigel
tnx!!! and if i want the last id on tlcontent only for div with class "trackon" ?
markzzz
A: 

$(".tlcontent div").last();

Alex