无法正常工作 errorJQuery 切换...可能很简单
我今天正在工作,决定开始使用 JQUERY 为搜索网站制作切换表...但我实际上像几天前一样开始使用 javascript 和 jquery。没有表格,它工作正常,但是当我添加表格时,它不会切换表格...我希望当您单击“过滤器搜索”时,表格会出现在下面,然后当您再次单击“过滤器搜索”时隐藏表格表...非常感谢任何帮助。这是代码(我已经在头部引用了jquery)
<div class='filtermore'>
<h4><a>Filter Search</a></h4>
<p style="display: none" class='jquery'>
<table border=0 width="875">
<tbody>
<tr>
<td width="164"><strong>City</strong></td>
<td width="176"><strong>Price</strong></td>
<td width="160"><strong>Features</strong></td>
</tr>
<tr>
<td><input type="checkbox"/> City 1</td>
<td><input type="checkbox"/> Cheap</td>
<td><input type="checkbox"/> Financing Available</td>
<td width="357"><input type="checkbox"/> Good for kids</td>
</tr>
<tr>
<td><input type="checkbox"/> City 2</td>
<td><input type="checkbox"/> Moderate</td>
<td><input type="checkbox"/> Smoking</td>
<td><input type="checkbox"/> Accepts Credit Cards</td>
</tr>
<tr>
<td><input type="checkbox"/> City 3</td>
<td><input type="checkbox"/> Expensive</td>
<td><input type="checkbox"/> Alcohol</td>
<td><input type="checkbox"/> Delivery</td>
</tr>
</tbody>
</table>
</p>
<script>
$("h4").click(function () {
$(".jquery").toggle("slow");
});
</script>
</div>
I was working today and decided to start using JQUERY to make a toggle table for a search site... but I literally started javascript and jquery like a couple days ago. Without the table, it works fine, but when I add the table it doesn't toggle the table...I want when you click on Filter Search for the table to come underneath and then when you click on filter search again to hide the table... Any help is much appreciated. Heres the code ( i already have jquery referenced in the head)
<div class='filtermore'>
<h4><a>Filter Search</a></h4>
<p style="display: none" class='jquery'>
<table border=0 width="875">
<tbody>
<tr>
<td width="164"><strong>City</strong></td>
<td width="176"><strong>Price</strong></td>
<td width="160"><strong>Features</strong></td>
</tr>
<tr>
<td><input type="checkbox"/> City 1</td>
<td><input type="checkbox"/> Cheap</td>
<td><input type="checkbox"/> Financing Available</td>
<td width="357"><input type="checkbox"/> Good for kids</td>
</tr>
<tr>
<td><input type="checkbox"/> City 2</td>
<td><input type="checkbox"/> Moderate</td>
<td><input type="checkbox"/> Smoking</td>
<td><input type="checkbox"/> Accepts Credit Cards</td>
</tr>
<tr>
<td><input type="checkbox"/> City 3</td>
<td><input type="checkbox"/> Expensive</td>
<td><input type="checkbox"/> Alcohol</td>
<td><input type="checkbox"/> Delivery</td>
</tr>
</tbody>
</table>
</p>
<script>
$("h4").click(function () {
$(".jquery").toggle("slow");
});
</script>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从技术上讲,你是在告诉
要切换的标签,而不是表格。虽然您会假设该表将从
继承,但表已被破坏且过时,并且在每个浏览器中呈现方式不同,因此您不能指望它们会关注。我会向表添加一个 ID 并在其上调用切换,或者使用 jQuery 中的子选择器(当然,您在第一周不会学到)直接定位表。像这样的事情:
Technically you are telling the <p> tag to toggle, not the table. While you would assume the table would inherit from the <p>, tables are busted and old-school and render differently in each browser, so you can't count on them to pay attention. I would add an ID to the table and call toggle on it, or use a child selector in jQuery (which you won't have learned the first week, for sure) to target the table directly. Something like this: