I have an unordered list with several divs contained inside. Each list item is created using jquery and placed in a variable.
I need a way: nth-child (even) of each div inside a jquery object.
ele = myList.append("<li> \
<div class='name'>"+this.name+"</div> \
<div class='test'>test</div> \
</li>");
How can I use the variable "ele" inside the jquery object to get the nth child contained inside?
What I imagined was not working:
$(ele+" div:nth-child(even)").addClass("my-class");
Another thing I imagined
ele.children("div:nth-child(even)").addClass('my-class'));
Also does not work.
source
share