在嵌套Div中使用Jquery隐藏列表2

时间:2012-02-06 14:50:06

标签: jquery list nested hide

尝试使用Jquery隐藏包含6个duv标签的List ITEM 2,其中一些不合格:

1-我的列表有6个潜水标签 2-是UL清单 3-选中按钮时,尝试显示/隐藏列表项目

<!--
       <div id="master_DefaultContent_rts_up">
        <div id="master_DefaultContent_rts_p">
        <div id="master_DefaultContent_rts_rt">
        <div id="master_DefaultContent_rts_ts3347_up">
        <div id="master_DefaultContent_rts_ts3347_t">
        <div class="rtsLevel rtsLevel1">
        <ul class="rtsUL">
        <li class="rtsLI rtsFirst tab_1071">
    <a class="rtsLink rtsSelected" href="#">
        <span class="rtsOut"><span class="rtsIn">
        <span class="rtsTxt">List 1</span>
        </span>
        </span>
        </a>
    </li>
        <li class="rtsLI tab_1072">
    <a class="rtsLink rtsAfter" href="#">
        <span class="rtsOut">
        <span class="rtsIn">
        <span class="rtsTxt">List 2
        </span></span></span>
    </a>
    </li>
        <li class="rtsLI rtsLast tab_1073">
    <a class="rtsLink" href="#"><span class="rtsOut">
        <span class="rtsIn"><span class="rtsTxt">List 3</span>
    </a>
    </li>
        </ul>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>
-->        

1 个答案:

答案 0 :(得分:0)

您应该能够通过类名找到元素。所以你可以这样做:(假设你想用隐藏/显示的复选框):

        //this would be the checkbox
        <input type="checkbox" id="chkTest">

        //this would go into the $(document).ready
        $("#chkTest").change(function () {
            var checked = $("#btnTest").is(":checked")                
            if (checked == true) {
                $(".rtsLI.tab_1072").find(".rtsTxt").hide() //this will hide
            } else {
                $(".rtsLI.tab_1072").find(".rtsTxt").show() //this will show
            };
        });