I want to find a parent for a button.
I have set up the html like the following.
<div id='user_123' class='user'>
<h1>My name goes here</h1>
<p>some description</p>
<a href='Javascript:{}' class='select'>
</div>

The thing is that I need to specify how many steps I have to go up to
get
the
parent id( see the bottom ) and if I add another tag I migh have to
change
this source. Is there any way to
specify using class ( maybe "$(this).parent(".user).attr("id") ?) so
that I
don't need
to specify how many level I have to go up in order to get that id?

$().ready(function(){
$(".select").click(function(){
    alert($(this).parent().attr("id"));
});
});

Thanks in advance.

Reply via email to