need help with jquery selector
- by Gandalf StormCrow
I have a following HTML :
<ul class="someclass">
<li id="1">
<button type="button" class="grey"></button>
</li>
<li id="2">
<button type="button" class="grey"></button>
</li>
<li id="44">
<button type="button" class="grey"></button>
</li>
<li id="54">
<button type="button" class="grey"></button>
</li>
</ul>
Now here is what I'm trying to accomplish with jquery :
When button is clicked to find out id of parent li, here is how I tried and failed:
$(".grey").live('click', function(){
alert($(this).parents("li").attr("id"));
alert($(this).parents("li:first").attr("id"));
});
Both give me null alerted, how can I do this ?