怎么通过js清空div中的内容

JavaScript011

怎么通过js清空div中的内容,第1张

document.getElementById('BIGDraw').innerHTML = ""

$('#BIGDraw').html("")

清空div内容 两种都可以

代码如下:

function addDiv(w,h){

deleteDiv()

//创建一个div

var my = document.createElement("divCell")

//添加到页面

document.body.appendChild(my)

my.style.position="absolute"

//通过样式指定x坐标(随机数0~450)

my.style.top= Math.round(Math.random()*450)

//通过样式指定y坐标(随机数0~700)

my.style.left= Math.round(Math.random()*700)

//通过样式指定宽度

my.style.width=w

//通过样式指定高度

my.style.height=h

//通过样式指定背景颜色,,若是背景图片 例为my.style.backgroundImage="url(img/3.jpg)"

my.style.backgroundColor="#ffffcc"

//添加div的内容

//my.innerHTML=i++

//设置样式透明

my.style.filter = "alpha(opacity=50)"

//设置ID

my.id = "divCell"

}

function deleteDiv()

{

var my = document.getElementById("divCell")

if (my != null)

my.parentNode.removeChild(my)

}