JQuery删除div无法在Internet Explorer中工作 [英] JQuery remove div not working in Internet Explorer

查看:79
本文介绍了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 * ** * ** * ** * **

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>

检查这个小提琴,它也在ie中工作。

Check this fiddle, it's working in ie too.

这篇关于JQuery删除div无法在Internet Explorer中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆