jquery单独切换

时间:2010-12-08 10:52:06

标签: javascript jquery html toggle

我的HTML是这样的:

<a class="tableheadlink" href="#">Impressions</a> <a href="#"><img src="images/table-sort.png" alt="" /></a>
<div class="filter-head">
    <form>
        <select name="website" class="rounded-all no-padding">
            <option value="opt1">&gt;</option>
            <option value="opt2">&lt;</option>
            <option value="opt3">=</option>
        </select>
        <input name="q" type="text" class="rounded-all small">
    </form>
</div>

jquery是这样的:

        $(".filter-head").hide();
        $("a.tableheadlink").click(function(){
            $(".filter-head").toggle();
            return false;
        });

我如何告诉它单独切换html部分的每个瞬间?页面上有大约10个实例,切换只是使用我的代码切换所有实例。

由于

1 个答案:

答案 0 :(得分:2)

您需要找到.filter-head this$(".filter-head").hide(); $("a.tableheadlink").click(function(){ $(this).nextAll(".filter-head:first").toggle(); return false; }); ,例如:

this

这样做是从{{1}}开始,然后将relative与您的班级选择器一起使用,并获得它遇到的.nextAll()切换。 :first而不是.nextAll()的原因是中间存在其他链接。