我在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>
答案 0 :(得分:1)
问题是由于我的嵌套ul。 因为我使用的是.parent():
,所以它没有被包裹在li中,这使得我的声明有问题var $categories = $(this).parent().next('.items')