jquery 单独切换
我的 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">></option>
<option value="opt2"><</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 个实例,切换将使用我的代码切换所有实例。
谢谢
My html is something like this:
<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">></option>
<option value="opt2"><</option>
<option value="opt3">=</option>
</select>
<input name="q" type="text" class="rounded-all small">
</form>
</div>
jquery something like this:
$(".filter-head").hide();
$("a.tableheadlink").click(function(){
$(".filter-head").toggle();
return false;
});
How do i tell it to toggle each instant of the html section individually? There is about 10 instances of it on the page and the toggle will just toggle all using my code.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要找到您想要的 相对< /a> 到
this
,例如:this 的作用是从
this
然后使用.nextAll()
与您的类选择器并获取:first
遇到要切换的一个。.nextAll()
而不是.next()
是中间有其他链接。You need to find the
.filter-head
you want relative tothis
, for example:What this does is go from
this
then uses.nextAll()
with your class selector and gets the:first
one it encounters to toggle. The reason for.nextAll()
instead of.next()
is that there is that other link in-between.