Hi Dave,
There are a few ways to do this. Probably the easiest is with :first-
child.
$('.set_list > dl.set:first-child').addClass('first');
That will add the class to all <dl class="set"> elements if they are a
child of .set_list and if they are the first child of their parent.
--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Oct 1, 2009, at 11:19 AM, Dave Maharaj :: WidePixels.com wrote:
I am trying to add a class to the first <dl> item each time it
appears inside set_list
$('.set_list').each(function(){
$('dl.set:first').addClass('first');
});
This appers to only add 'first' to the first dl and not each one in
each set_list
I have my code like below..i simply want to add 'first' to the first
dl in each set_list
set_list
dl <= i want first added here
dt
dd
dl
dt
dd
set_list
dl <= i want first added here
dt
dd
dl
dt
dd
Know where i went wrong?
Dave