兄弟姐妹的jQuery选择器?

时间:2010-08-25 07:13:11

标签: jquery jquery-selectors

我正在尝试为兄弟的孩子提供一个jQuery选择器(页面上有多个部分,所以需要到达兄弟的孩子(而不是能够使用常规选择器)。

HTML:

<div class="tour-section">
                <div class="screenshots left">
                    <div class="tab tab1"></div>
                    <div class="tab tab2"></div>
                    <div class="tab tab3"></div>
                    <div class="tab tab4"></div>
                </div>
                <div class="talking-point section1">
                    <h2 class="primary-color-text">Create your listing</h2>
                    <p class="subheader">Create your job listing by adding a few simple details</p>
                </div>
</div>

JS:

$(".talking-point.section1").mouseenter(function() {
            $(this).siblings(".screenshots").children("tab").hide();
            $(".screenshots .tab1").show();
            $(this).siblings(".screenshots").css("background-position","0 0");
        }); 

3 个答案:

答案 0 :(得分:16)

逻辑上它应该有效。您错过了. Jquery选择器的点.children()

.children(".tab")

答案 1 :(得分:7)

Using find instead of children worked for me:

$(this).siblings(".screenshots").find("tab")

答案 2 :(得分:2)

您的意思是children(".tab")吗?

相关问题