【问题标题】:slideToggle() does not work properly in IE7slideToggle() 在 IE7 中无法正常工作
【发布时间】:2013-08-26 20:53:46
【问题描述】:

我在 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>

【问题讨论】:

  • 你用的是什么 jQuery 版本?
  • Aaa 我发现了这个问题。问题是我的嵌套
      没有包含在
    • 中。我正在使用 jquery-1.10.2。

标签: javascript jquery html internet-explorer internet-explorer-7


【解决方案1】:

问题是由于我的嵌套 ul。 它没有被包裹在一个 li 中,这使得我的声明错误,因为我使用了 .parent():

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 2010-09-16
    • 1970-01-01
    • 2012-06-12
    • 2011-11-02
    • 1970-01-01
    相关资源
    最近更新 更多