Javascript slideToggle()在IE7中无法正常工作
我在IE7中遇到jQuery SlideToggle问题。 它在IE8、IE9、FF、Chrome和Opera中正常工作。 当我调试时,我没有得到任何错误。唯一正在发生的事情是我的event.preventDefault(),但出于某种原因,IE7甚至没有尝试在我的if语句之后做任何事情。 下面是一些代码:Javascript slideToggle()在IE7中无法正常工作,javascript,jquery,html,internet-explorer,internet-explorer-7,Javascript,Jquery,Html,Internet Explorer,Internet Explorer 7,我在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
/* 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.categories')。在('click','toggle button',函数(事件){
event.preventDefault();
var$categories=$(this.parent().next('.items'),
$icon=$('.icon',this);
$categories.slideToggle(Interface.animationDuration,function()){
//这里的某个地方停了下来。它甚至不会滑动切换。
如果($(this).is(':visible')){
$icon.removeClass('white-arrow-down').addClass('white-arrow-up');
}否则{
$icon.removeClass('white-arrow-up').addClass('white-arrow-down');
}
});
});
-
-
问题是由我的嵌套ul造成的。
因为我使用的是.parent(),所以它没有封装在导致my声明错误的li中:
您使用的jQuery版本是什么?aa我发现了问题。问题是我的嵌套
- 没有封装在
- 中。我正在使用jquery-1.10.2。
var $categories = $(this).parent().next('.items')