On Feb 15, 2007, at 11:01 AM, Mahadewa wrote:
// This function is wired to the above buttons' onclick event,
passing
'this' as an argument
function OnButtonClick(source)
{
var parent = $(".parent").children(source.id);
}
Hi Chris,
you should be able to do it this way:
var parent = $(this).parents('div.parent');
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Feb 15, 2007, at 11:01 AM, Mahadewa wrote:
Hi all,
I've got the following problem ...
Let's say I have the following html:
<div class="parent" id="parent1">
<div class="sub">
<input id="parent1_Button" class="mybutton" type="button"
value="button" />
</div>
</div>
<div class="parent" id="parent2">
<div class="sub">
<input id="parent2_Button" class="mybutton" type="button"
value="button" />
</div>
</div>
Now given a JQuery object of any of the button, how can I select
its parent
div (the one with the class "parent") ?
I have tried the following, but it doesn't seem to yield the
correct object:
// This function is wired to the above buttons' onclick event,
passing
'this' as an argument
function OnButtonClick(source)
{
var parent = $(".parent").children(source.id);
}
Thanks a lot !
Chris
--
View this message in context: http://www.nabble.com/Parent-
Selection-Problem-tf3234532.html#a8987992
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/