Parent element selection problem?
Posted
by Starx
on Stack Overflow
See other posts from Stack Overflow
or by Starx
Published on 2010-06-09T07:21:42Z
Indexed on
2010/06/09
7:32 UTC
Read the original article
Hit count: 133
My HTML is something like this
<div id="mydiv" class="common">
<input type="text" id="text1" value="" />
<input type="text" id="text2" value="" />
</div>
I am assigning a function on the onclick event of the textbox like this
$(document).ready(function() {
$(".common input").click(function() {
//////// What I am trying to do is access the id of its parent
// in this case it is "mydiv"
alert($(this:parent).attr('id'));
});
But it is not working
© Stack Overflow or respective owner