JQuery 删除 div 在 Internet Explorer 中不起作用 [英] JQuery remove div not working in Internet Explorer
本文介绍了JQuery 删除 div 在 Internet Explorer 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不是真正的 javascript/jquery 编码员,我有一个非常简单的代码来删除在 IE 中不起作用的 div
I'm not really a javascript/jquery coder, I have a very simple code to remove a div that's not working in IE
我在 Joomla 页面中使用它,所以我这样称呼它:
I'm using this in a Joomla page, so I call it like this:
$document->addScript("http://code.jquery.com/jquery-latest.js");//adiciona jquery
然后,在正文文件中:
<script>
setTimeout(function() {
$("#yourDiv").remove();
}, 50000);
</script>
FireFox 和 Chrome(一如既往)没问题.有人可以指出我的错误吗?非常感谢:)
FireFox and Chrome are (as always) ok. Can someone point out my mistake please? Thanks a lot :)
已编辑************
EDITED ************
我也试过用这段代码没有 jquery,但总是不能在 IE (9) 中工作
I've tryied also with this code no jquery, but always not working in IE (9)
<script>
setTimeout('yourFunction();', 5000);
function yourFunction(){
var div = document.getElementById("yourDiv");
div.parentNode.removeChild(div);
}
</script>
推荐答案
<script>
$(document).ready(function(){
setTimeout(function() {
$("#yourDiv").remove();
}, 50000);
});
</script>
检查这个 fiddle,它也在 ie 中工作.
Check this fiddle, it's working in ie too.
这篇关于JQuery 删除 div 在 Internet Explorer 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文