How do you select a div which is a child of the current $(this)?
I have many divs with the class row, in each of which I have a hidden div called form_explanation. I want to show() the div form_explanation when the row is onClick-ed.
Thanks!
How do you select a div which is a child of the current $(this)?
I have many divs with the class row, in each of which I have a hidden div called form_explanation. I want to show() the div form_explanation when the row is onClick-ed.
Thanks!
Share Improve this question edited Jun 17, 2010 at 19:23 EndangeredMassa 17.5k8 gold badges56 silver badges81 bronze badges asked Jun 17, 2010 at 19:23 WalkerWalker 135k29 gold badges69 silver badges97 bronze badges3 Answers
Reset to default 9$('.row').bind('click', function () {
$(this).children('div.form_explanation').show();
});
If you want to hide all other divs:
$('.row').bind('click', function () {
$('div.form_explanation:visible').hide();
$(this).children('div.form_explanation').show();
});
$(this).children("div.form_explanation")
try this out for your specific problem
$('.row').click(function() {
$('div#form_explanation').show('fast'); //or div.form_explanation you didn't specify
});
with regards to the first part of your question, you could do something like this in general:
$(this).children('div');
or something like if you don't have the $(this)
$('parent > child');