使用javascript从div标签中删除内容 [英] remove content from div tag using javascript
本文介绍了使用javascript从div标签中删除内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的div标签:
I have a div tag like this:
<div id="div1" runat="server"></div>
我写了一个Javascript,在这个div标签中添加了像0,1,2,3这样的内容作为其内容。
现在我想要一个会删除一些脚本的脚本此div的内容为ex 0,2,3。
如何从div标签中删除内容。
I wrote a Javascript which adds content like 0,1,2,3, in this div tag as its content.
Now I want a script which will delete some of the content of this div for ex 0,2,3.
How can I remove content from div tag.
推荐答案
document.getElementById('divStatus').innerHTML = "";
var divStatus = document.getElementById("divStatus");<br />
divStatus.innerText = divStatus.innerText.replace("0,1","");
投票如果它有帮助
vote if it helps
使用
Use
function LoadResponse(response,control)
{
var container = document.getElementById(control);
try
{
while(container.firstChild)
container.removeChild(container.firstChild);
var t = document.createElement('div');
t.innerHTML = response;
container.appendChild(t);
}
catch(ex)
{
container.innerHTML = response;
}
}
现在拨打 LoadResponse('',divid)
它将完全删除内容。
Now call LoadResponse('', divid)
It will remove the content totally.
这篇关于使用javascript从div标签中删除内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文