简体   繁体   English

jQuery切换无法在IE中使用

[英]jQuery toggle not working in IE

I have some jQuery code that works absolutely fine on everything other than IE. 我有一些jQuery代码在IE之外的所有其他软件上都可以正常工作。 The toggle action doesn't trigger and doesn't hide or show the footer element. 切换动作不会触发,也不会隐藏或显示页脚元素。

I have tried to use a conditional if and else statement to use hide() and show() instead of toggle, I have also tried adding language and src elements to the script tag but neither of these angles worked. 我试图使用条件if和else语句来使用hide()和show()来代替切换,我也试图将language和src元素添加到script标签中,但是这些角度都不起作用。 I have the latest doctype declared and i'm using the latest version of wordpress. 我声明了最新的doctype,并且使用的是最新版本的wordpress。

Can anyone see why this isn't working in IE? 谁能看到为什么这在IE中不起作用?

<script>
$(document).ready(function() {
    $("#clickme").click(function() {
        event.preventDefault()
        $("#footer").toggle(2000);
        $('#menu, #menu2, #menu3, #menu4').hide('slow');
        $(this).html(($('#clickme').text() == 'Show') ? 'Hide' : 'Show');
        $(this).toggleClass("active");
        $(this).attr("title", ($(this).hasClass("active") ? "Show" : "Hide") + " the menu");
    });
});​
</script>

You are using 您正在使用

$("#clickme").click(function() {
    event.preventDefault();//^ event parameter is missing, so causing error
    // ...
});

It should be 它应该是

$("#clickme").click(function(event) {
    event.preventDefault(); // ^
    // ...
});

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

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