我刚接触jQuery,但是已经发现了内置的slideDown()/slideUp()动画存在问题。我正在使用一个具有灵活宽度的元素,在使用该函数时,该元素不会返回到其完整的宽度。我认为这可能与jQuery查找元素宽度的方式有关。我在Safari 3和Firefox 3.1 for OS X中遇到了这个错误。以下是页面的html代码:
<div id="archive">
<h2 class="first open">May</h2>
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="list">
<tr class="first">
<td width="65%"><a href="#">This month</a></td>
<td align="right">Sunday, May 31 <input type="button" value="Edit"/></td>
</tr>
</table>
</div>
以下是JavaScript代码:
// Enable month names to re-open divs
$("#archive h2").not(":last").wrapInner("<a href='#'></a>").end().find
("a").click(function(event){
event.preventDefault();
var h2 = $(this).parent();
if (h2.hasClass("open")) { // Close
h2.removeClass("open");
h2.next().slideUp("fast");
} else { // Open
h2.addClass("open");
h2.next().slideDown("fast");
}
});
问题可以通过将
包裹在中来解决,但是在Firefox中会出现新的错误,在slideDown动画接近结束时跳跃。
任何帮助都将不胜感激。
谢谢,
Brendan