【发布时间】:2010-03-10 21:21:50
【问题描述】:
为什么这两个函数有奇怪的行为,当我点击广告时,tbody 展开然后折叠。
第二个函数可以做一些测试,向 if、else 语句添加警报,但它只进入 if 语句,所以它只会滑动。
我注意到的另一件事是,当 tbody 中只有一行时,它可以正常工作。为什么?
我也尝试添加return false,什么都没有,它没有被调用两次或在任何其他地方的函数。
如果我能解决这个问题,我将不胜感激。
谢谢。
Function 1
$(function() {
$("table.section thead").click(function() {
$(this).next("table.section tbody").slideToggle("slow");
});
});
Function 2
$(function() {
$("table.section thead").click(function() {
var body = $(this).next("table.section tbody");
if (body.is(":visible"))
body.slideUp("slow");
else
body.slideDown("slow");
});
});
更新 表格
<table>
<thead>
<tr><td>heading></td></tr>
</thead>
<tbody>
<tr><td>content1</td></tr>
<tr><td>content2</td></tr>
</tbody>
</table>
【问题讨论】:
-
这两个函数是同时绑定的,还是这两个尝试做同样的事情?
-
@Sorpigal - 这是他之前的问题的 2 次不同尝试。
-
我只使用其中一种功能。这是我分别尝试的两个功能