Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

In jQuery, what does this selector mean?

I'm new to javascript and jquery.

What does this selector mean: " #LayoutColumn2 > div > div > div > ul"

Context(the function it is in) :

$("#placeholderForLoad").load(changedItemValue + " #LayoutColumn2 > div > div > div > ul", function(){

$("#placeholderForLoad li").each(function(){

var itemName = $(this).children("a").text();

var itemValue = $(this).children("a").attr("href");

linkArray.push(itemValue+";"+itemName);

});

if (tierID == "tier1") {

tierID = "tier2";

}

else if (tierID == "tier2"){

tierID = "tier3";

}

else if (tierID == "tier3") {

tierID = "tier4";

}

resetTiers(tierID);

fillMyList(linkArray, tierID);

});

1 Answer

Relevance
  • 9 years ago
    Favorite Answer

    The > symbol is used to select the direct child of the parent element.

    Let's say you had the following html:

    <section>

    <p></p>

    <div>

    <p></p>

    </div>

    </section>

    If your css selector is "section p" that would match both p elements since they are descendants of the section element. However, if your selector is "section > p" that would only match the first p element because it's a direct child of the section element.

    So the selector, "#LayoutColumn2 > div > div > div > ul", will select a ul element that's a direct child of its parent div, which itself is a direct child of its parent div, which itself is a direct child of its parent div, which itself is a direct child of the element with id=LayoutColumn2.

    The html that it would match is:

    <div id="LayoutColumn2">

    <div>

    <div>

    <div>

    <ul>

    </ul>

    </div>

    </div>

    </div>

    </div>

Still have questions? Get your answers by asking now.