资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
添加、删除HTML结点 & 上传图片预览
1.添加、删除HTML结点
2.上传图片预览
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312"> <head> <title> 添加、删除HTML结点 & 上传图片预览 </title> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <meta name="author" content="枫岩,http://www.cnlei.com"> <meta name="keywords" content="" /> <meta name="description" content="" /> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0A%3C!--%20%0D%0Afunction%20AddChild(sPid)%7B%20%0D%0Avar%20oTextNode%20%3D%20document.getElementById(%22TplNode%22).getElementsByTagName(%22li%22)%5B0%5D%3B%20%0D%0Avar%20oClone%20%3D%20oTextNode.cloneNode(oTextNode)%3B%20%0D%0Avar%20p%3Ddocument.getElementById(sPid)%3B%20%0D%0Ap.appendChild(oClone)%3B%20%0D%0A%7D%20%0D%0A%0D%0Afunction%20DelChild(o%2CsPid)%7B%20%0D%0Avar%20oTextNode%20%3D%20o.parentNode%3B%20%0D%0Avar%20p%3Ddocument.getElementById(sPid)%3B%20%0D%0Ap.removeChild(oTextNode)%3B%20%0D%0A%7D%20%0D%0A%0D%0Afunction%20PreviewImg(o%2CsPid)%7B%20%0D%0Adocument.getElementById(sPid).src%3Do.value%3B%20%0D%0A%7D%20%0D%0A%0D%0A--%3E%20%0D%0A%3C%2Fscript%3E"> </head> <body> <ul id="TplNode" style="display:none;"> <li><input type="file" name="" value="" size="64" onchange="PreviewImg(this,'PrevImg');" /> <a href="javascript:;" _ewebeditor_ta_href="javascript%3A%3B" onclick="DelChild(this,'UpFiles');">删除</a></li> </ul> <ul id="UpFiles"> <li><input type="file" name="" value="" size="64" onchange="PreviewImg(this,'PrevImg');" /> <a href="javascript:;" _ewebeditor_ta_href="javascript%3A%3B" onclick="DelChild(this,'UpFiles');">删除</a></li> </ul> <p><a href="javascript:;" _ewebeditor_ta_href="javascript%3A%3B" onclick="AddChild('UpFiles');">增加附件</a></p> <p>图片预览:<br><img id="PrevImg" src="http://www.iecn.net/images/user_icons/2006/10/01/u_35653.gif" _ewebeditor_ta_src="http%3A%2F%2Fwww.iecn.net%2Fimages%2Fuser_icons%2F2006%2F10%2F01%2Fu_35653.gif" alt="" /></p> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程