Home >Web Front-end >JS Tutorial >How to clear all tags under div_javascript tips

How to clear all tags under div_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:59:451328browse
复制代码 代码如下:




1




1







复制代码 代码如下:

function add1(){//添加一个div content-main
var obj=document.createElement("div");
obj.id="content-main";
obj.innerHTML='
'
'3'
'
';
$('#slides').append(obj);
}

function clear(){//清除slides下的所有div和img
var div1=document.getElementById("slides").getElementsByTagName("div");
for(var i=0;idiv1[i].innerHTML='';
}
}

复制代码 代码如下:

function ClearAllText(divInput){ //清空div下多有text文本框的内容,重置
var txts = document.getElementById('divInput').getElementsByTagName("input");
for(var i=0;i{
if(txts[i].type=="text"){
txts[i].value =""; //text 清空
}
}
var selects = document.getElementById('divInput').getElementsByTagName("select");
for(var i=0;i{
selects[i].options[0].selected = true; //选择第一项
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn