質問

I want to make some jquery slider function. Im using code:

var parentElement = $('#slidercontent');

In this object i have a ul element with li elements (childrens). I want to make a each function and get all childrens of this element.

I try some combinations for ex:

parentElement.each(function(){ 
console.log('its a li!');
});

parentElement.children().each(function(){ 
console.log('its a li!');
});

but this not working effective.

役に立ちましたか?

解決

$(function(){
    var parentElement = $('#slidercontent');
    parentElement.children().each(function(){ 
       //use $(this).children() to get children's children
       console.log($(this).children());
   });
});

DEMO: http://jsfiddle.net/dirtyd77/VfD52/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top