Walker
Walker

Reputation: 134721

jQuery selector for child of sibling?

I'm trying to get a jQuery selector for the child of a sibling (multiple sections on the page so need to just reach the sibling's child (rather thna being able to use a general selector).

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");
        }); 

Upvotes: 29

Views: 44698

Answers (3)

jAndy
jAndy

Reputation: 236202

Logically it should work. You're missing a dot . for the .children() Jquery selector.

.children(".tab")

Upvotes: 27

warvariuc
warvariuc

Reputation: 59674

Using find instead of children worked for me:

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

Upvotes: 16

kennytm
kennytm

Reputation: 523784

Do you mean children(".tab")?

Upvotes: 4

Related Questions