其他分享
首页 > 其他分享> > 清空多个<input type=‘text‘>中的数据

清空多个<input type=‘text‘>中的数据

作者:互联网

清空多个指定id的 中的数据,同时赋值为“0”
input中必须加上name=xingming id=xingming浏览器兼容、急速模式下才能正常使用
好像加上name=xingming 就正常了!!

<script>
function myclear()
{
for(i=0;i<document.getElementsByName("xingming").length;i++)
if(document.getElementsByName("xingming")[i].type=="text")
document.getElementsByName("xingming")[i].value="0";
}
</script><input type='text' value=1 >
<input name=xingming type='text' value=1 id=xingming>
<input name=xingming type='text' value=2 id=xingming>
<input name=xingming type='text' value=3 id=xingming>
<input  type='button' value='clear' onclick='myclear()'>

标签:xingming,name,多个,text,清空,input,type,id
来源: https://blog.csdn.net/ldl0554/article/details/112361970