【问题标题】:jquery .hide() and show() not working in IEjquery .hide() 和 show() 在 IE 中不起作用
【发布时间】:2015-08-10 19:14:23
【问题描述】:

我有 IE 11,当我尝试这段代码时,它在 firefox 和 chrome 中有效,但在 IE 中无效,有什么解决方法吗?

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">  </script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
    $("p").hide();
});
$(".btn2").click(function(){
    $("p").show();
});
});
</script>
</head>
<body>

<p>This is a paragraph.</p>

<button class="btn1">Hide</button>
<button class="btn2">Show</button>

</body>
</html>

【问题讨论】:

  • 对我来说似乎工作正常
  • 您的意思是您的p 元素没有隐藏或显示在IE11 中吗?我不能重复你的问题:jsFiddle
  • 和我的资源管理器一起工作也很好
  • 您是否检查过 IE 是否阻止了外部 JQuery 脚本的加载?您可以成功使用任何其他 JQuery 函数吗?您的示例在 IE10 中运行良好
  • 并尽量避免为 CDN 链接指定协议。即://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js

标签: jquery html cross-browser


【解决方案1】:

我已经在多个版本的 IE 中检查了您的脚本,并且该脚本甚至可以在 IE 5 等旧版本中运行。

就像其他人之前提到的,确保 IE 没有阻止外部文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多