补充一下主要是function del()这个函数怎么判断元素是否已经存在了。多谢各位能够给予解答!
解决方案 »
- JavaScript 将鼠标指针替换成图片
- extjs datefield设置不为空
- jquery toggle问题
- 关于窗口特效的JS代码
- 可拖动改变大小的div
- insertAdjacentElement 在firefox下报错的问题。
- javascript 各个版本之间有什么不同?
- 请问如何在javascript中删除一个表格,(使用dhtml)
- 帮忙看看这段代码怎么改啊?
- 怎样用JS判断一个上传文件的名字是不是中文和它的类型
- 问:想要鼠标滑到某张图片或文字上是显示注解。怎么弄?
- asp中默认的语言是vbscript,怎样改成javascript?这样在调用ASP的内建对象时有什么不同?
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
function add(){
newObj = document.createElement('Input');
newObj.id="tttttt";
newObj.type="text";
newObj.name="mytest";
newObj.value="hello";
currectObj = document.getElementById('p1');
currectObj.appendChild(newObj);
}
function del(){
if(document.getElementById('tttttt') != null){
alert("It Exist!");
}
}
</script>
</head><body><form name="form1" method="post" action="">
<p id="p1"> </p>
<input type="button" name="Button" value="add" onClick="add();">
<input type="button" name="Button" value="del" onClick="del();">
</form>
<p> </p>
</body>
</html>