[英]slideToggle() does not work properly in IE7
I am experiencing problems with jQuery SlideToggle in IE7. 我在IE7中遇到jQuery SlideToggle的问题。 It works properly in IE8, IE9, FF, Chrome, Opera.
它可以在IE8,IE9,FF,Chrome,Opera中正常运行。 When i debug i don't get any errors.
当我调试时,我没有任何错误。 The only thing that's happening is my event.preventDefault() but by some reason IE7 isn't even trying to do anything after my if statement.
唯一发生的事情是我的event.preventDefault(),但是由于某种原因,IE7甚至没有在if语句之后尝试执行任何操作。 Here is some code:
这是一些代码:
/* 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>
The issue was due to my nested ul. 问题是由于我的巢状ul。 It was not wrapped inside a li which made the my declaration faulty since i was using .parent():
它没有包装在li中,这使我的声明有误,因为我正在使用.parent():
var $categories = $(this).parent().next('.items')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.