[英]slideToggle() does not work properly in IE7
我在IE7中遇到jQuery SlideToggle的问题。 它可以在IE8,IE9,FF,Chrome,Opera中正常运行。 当我调试时,我没有任何错误。 唯一发生的事情是我的event.preventDefault(),但是由于某种原因,IE7甚至没有在if语句之后尝试执行任何操作。 这是一些代码:
/* For handling of open/close the toggler button for categories */
$('ul.categories').on('click', '.toggle button', function(event) {
event.preventDefault();
var $categories = $(this).parent().next('.items'),
$icon = $('.icon', this);
$categories.slideToggle(Interface.animationDuration, function() {
//Somewhere here is stops. It does not even slideToggle.
if ($(this).is(':visible')) {
$icon.removeClass('white-arrow-down').addClass('white-arrow-up');
} else {
$icon.removeClass('white-arrow-up').addClass('white-arrow-down');
}
});
});
<ul class="categories">
<li class="toggle"><button type="button"><span class="icon white-arrow-down"></span></button></li>
<ul class="items">
<li>
<input type="radio" name="category" id="" value=""><label for=""></label>
</li>
<li>
<input type="radio" name="category" id="" value=""><label for=""></label>
</li>
</ul>
</ul>
问题是由于我的巢状ul。 它没有包装在li中,这使我的声明有误,因为我正在使用.parent():
var $categories = $(this).parent().next('.items')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.