【发布时间】:2011-08-21 15:11:53
【问题描述】:
我有一个包含内容的表格和一个图像,单击该图像会显示 div 中包含的隐藏内容。这个 div 有另一个表格来格式化内容。现在,当我在 IE 和 chrome 中对此进行测试时,隐藏的内容会根据单击的按钮上下滑动。但是当我在 Firefox 中执行此操作时,内容只是出现并消失,没有平滑的滑动。谁能告诉我为什么。如果我将显示按钮移出顶部表格并将其插入两个表格之间,则上下滑动可以顺利进行。唯一的问题是我需要显示按钮在内容中
我的脚本是这样的
<script type="text/javascript">
//<![CDATA[
$(function() {
$(document).ready(function() {
$(".slidingDiv").hide()
$('.show').click(function() {
$(".slidingDiv").slideDown(1000);
return false;
});
$('.hide').click(function() {
$(".slidingDiv").slideUp(1000);
return false;
});
});
});
//]]>
</script>
出现在页面头部
然后我的页面正文代码看起来像
<table style="width: 100%;" align="left" border="0">
<tbody>
<tr>
<td>content here</td>
<td>and here</td>
<td><a class="show"><img src="images/more.jpg" onmouseout="this.src='images/more.jpg';" onmouseover="this.src='images/more_over.jpg';" /></a></td>
</tr>
</tbody>
</table>
<div class="slidingDiv">
<table style="width: 100%;" align="left" border="0">
<tbody>
<tr>
<td>content hidden</td>
<td>content hidden</td>
<td>content hidden</td>
</tr>
<tr>
<td>content hidden</td>
<td>content hidden</td>
</tr>
<tr>
<td>content hidden</td>
<td>content hidden</td>
</tr>
</tbody>
</table>
<a class="hide"><img src="images/close.jpg" onmouseout="this.src='images/close.jpg';" onmouseover="this.src='images/close_over.jpg';" /></a>
</div>
【问题讨论】:
-
顺便说一句,$(function() {});是 $(document).ready(function() {}) 的简写; - 无需在此处包装内部调用。
标签: jquery show show-hide slidedown slideup