slideToggle()在IE7中无法正常工作

slideToggle() does not work properly in IE7

本文关键字:常工作 工作 IE7 slideToggle      更新时间:2023-09-26

我在IE7中遇到jQuery SlideToggle问题。它可以在IE8、IE9、FF、Chrome、Opera中正常工作。当我调试时,我没有得到任何错误。唯一发生的事情是我的event.prventDefault(),但由于某种原因,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中,这使得我的声明有错误,因为我使用了.pert():

var $categories = $(this).parent().next('.items')