javascript - 识别 Jquery 选择器

标签 javascript jquery jquery-selectors

我是 javascript 和 jquery 的新手。

这个选择器是什么意思:“#LayoutColumn2 > div > div > div > ul”

Contect(它来自的函数):

function loadNextTier(tierID, changedItemValue) {
    linkArray.length = 0;
$("#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);
});

最佳答案

它将匹配以下结构

<any_tag id="LayoutColumn2">
  <div>
    <div>
      <div>
        <ul> <-- matches this tag
          <li>
            <ul> <-- doesn't match. you only fetched children, not descendants

#LayoutColumn2 > div > div > div > ul意思是:

get the <ul> that is a child of a <div>, which is a child of a <div>, which is a child of a <div>, which is a child of a tag with an id of LayoutColumn.

顺便说一句,术语“后代”是指嵌套在某个元素中(无论多深)的任何元素。没有组合器的 CSS 选择器通常以后代为目标。

术语表示直接后代的元素或距离该元素仅1层深度的后代元素。这就是 > 的目的.

关于javascript - 识别 Jquery 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10972510/

相关文章:

javascript - 如何测试变量中的某个数字?

javascript - 隐藏其类与单击的按钮不匹配的 div 的按钮菜单

javascript - 在 getDay 方法之后更改文本

jquery - 如何使用jquery选择另一个特殊标签后的特殊标签

javascript - 在 Javascript 中使用 Jquery 变量

javascript - 动态选择 img 来更改其来源的问题

javascript - 如何在javascript中将String转换为long?

javascript - 如何在 TinyMCE 4 中设置内容,最好是在 $(document).ready(); 中堵塞?

php - 如何将 Jquery Validate Plugin 与 recaptcha 集成?

javascript - 使用 InstantSearch.js 在运行时选择不同的模板