[英]javascript - Jquery toggle error in Internet Explorer 8 and below
In internet explorer <=8 i got toggle error. 在Internet Explorer <= 8中,出现切换错误。 I am using jquery-1.7.1.
我正在使用jquery-1.7.1。 Thanks!
谢谢! JS code:
JS代码:
function myFunction1() {
document.getElementById("dropdown-content1").classList.toggle("show");
}
So when press <a onclick="myFunction1()" id="shopbtn" href="#">Shop</a>
it should add show
class to block with id dropdown-content1
. 因此,当按
<a onclick="myFunction1()" id="shopbtn" href="#">Shop</a>
,应添加show
类以阻止ID为dropdown-content1
。
You aren't using any jQuery functions in that code. 您没有在该代码中使用任何jQuery函数。 Everything in it is standard JavaScript and DOM.
其中的所有内容都是标准的JavaScript和DOM。
classList
is too new for IE8 to support (and IE8 is too old for Microsoft to support ). classList
对于IE8来说太新而不能支持 ( 对于Microsoft来说IE8太老了 )。
If you wanted to use jQuery then you could use: 如果您想使用jQuery,则可以使用:
jQuery("#dropdown-content").toggleClass("show");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.