开发者

Grabbing first item in a set

开发者 https://www.devze.com 2023-01-25 04:01 出处:网络
I am trying to grab the first item in a set but none of the examples i have seen on traversing really fit the format I am using. Any help would be greatly appreciated.

I am trying to grab the first item in a set but none of the examples i have seen on traversing really fit the format I am using. Any help would be greatly appreciated.

function popagateDegreeUpwards(obj, sectionNum, compLev, counter)
{
    var ddl = $(obj);
    var oneTierUpPnl = ddl.parent('.Section' + (sectionNum - 1));
    var parDdls = oneTierUpPnl.find(开发者_运维百科'.DDLSelector' + (sectionNum - 1));
    var parDdl = //How do I select the first element in the parDdls Set???
}


Use the :first selector. Here's some documentation: http://api.jquery.com/first-selector/

You might use it like so:

function popagateDegreeUpwards(obj, sectionNum, compLev, counter)
{
    var ddl = $(obj);
    var oneTierUpPnl = ddl.parent('.Section' + (sectionNum - 1));
    var parDdls = oneTierUpPnl.find('.DDLSelector' + (sectionNum - 1));
    var parDdl = $(':first', parDdls);
}

You could also use the .first() call. Docmentation here: http://api.jquery.com/first/

Usage example:

function popagateDegreeUpwards(obj, sectionNum, compLev, counter)
{
    var ddl = $(obj);
    var oneTierUpPnl = ddl.parent('.Section' + (sectionNum - 1));
    var parDdls = oneTierUpPnl.find('.DDLSelector' + (sectionNum - 1));
    var parDdl = parDdls.first();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消