最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do you select a specific child div with jQuery? - Stack Overflow

programmeradmin4浏览0评论

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 badges
Add a ment  | 

3 Answers 3

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');
发布评论

评论列表(0)

  1. 暂无评论