HI I have following problem, i have a ul list like this one
<ul class="ul">
<li id="li1">
<span class="widget">
<input name='try1' value="try1" class="param" />
</span>
<ul>
<li class="li2">
<span class="widget">
<input name='try1' value="try1" class="param" />
<input name='try2' value="try2" class="param" />
</span>
</li>
</ul>
</li>
<li id="2"></li>
</ul>
my problem is when i try to get inputs in this way
$('#li1 .param').each(function(){
alert($(this).attr('name'));
});
each returns to me
try1
try1
try2
But i need only these ones between span if someone knows how to get them?
Thank you in advance !
Hard to understand, but I assume you mean that you only want the ones that descend from the child
<span>element instead of all<span>elements.If so, do this:
This uses the the
child-selector(docs) to target.paramelements that descend from a<span>element that is a child of#li1.