[英]Dynamic jQuery identifier gives “Object doesn't support this property or method” in IE8, using jquery 1.7.2
does somebody know, why this throws an error in IE8? 有人知道,为什么这会在IE8中引发错误吗?
$(function(){
function activateTab(name){
identifier = '#' + name;
container = $(identifier);
}
});
thanks for any advise. 感谢您的任何建议。
Should work fine, wrap your code in $(document).ready function, like 应该可以正常工作,将您的代码包装在$(document).ready函数中,例如
$(document).ready(function() {
alert(activateTab("test"));
});
function activateTab(name){
identifier = '#' + name;
container = $(identifier);
return container;
}
<div id="test">Tested</div>
Try: 尝试:
$(function(){
function activateTab(name){
identifier = '#' + name;
container = $(identifier);
return container;
}
alert(activateTab("test"));
});
This is also working fine for me 这对我也很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.