简体   繁体   English

简单的jQuery代码在IE9中不起作用

[英]Simple jQuery code won't work in IE9

This is my small piece of code for hide-show tabs (like an accordion): 这是我的隐藏显示标签(如手风琴)的一小段代码:

$('#multiOpenAccordion h3').click(function() {
    $(this).next().toggle('slow');
    return false;
});

It is just a copy-paste from the jQuery site - it works in all broswers (including IE7 & IE8) but not IE9. 它只是jQuery网站上的复制粘贴-适用于所有浏览器(包括IE7和IE8),但不适用于IE9。

this is even not a jQuery-UI - only simple jQuery 这甚至不是jQuery-UI-仅是简单的jQuery

Why doesn't it work in IE9? 为什么它在IE9中不起作用? How can this be fixed? 如何解决?

Here is my HTML: 这是我的HTML:

<div id="multiOpenAccordion">


                        <h3>
                            <a href="#">
                                <h4>
                                    My Car Proj
                                    <span>Free</span>
                                </h4>
                                <p>
                                    site
                                </p>
                            </a>
                        </h3>
                        <div>Lorem ipsum</div>
                        <h3>
                            <a href="#">
                                <h4>
                                    My Car Probsp;
                                    <span>Free</span>
                                </h4>
                                <p>
                                    bla bla
                                </p>
                            </a>
                        </h3>
                        <div>Lorem ipsum</div>
</div>

if your next points a href in html, try giving these 如果您的下一个指向html中的href,请尝试给这些

"href=javascript:void(0)"

then delete your return false 然后删除您的返回false

由于某些未知原因,从标头中删除<p>元素解决了该问题(仅在IE9中发生)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM