资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
javascript一段创建层的代码
<html> <head> <style> .aaa { border:1px solid #ccc; background:#f60; height:200px; } </style> <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%0Afunction%20cdiv()%7B%20%0D%0A%20%20%20%20var%20createDiv%20%3D%20document.createElement(%22div%22)%3B%20%0D%0A%20%20%20%20createDiv.setAttribute(%22class%22%2C%22aaa%22)%20%0D%0A%20%20%20%20%2F%2FcreateDiv.style.border%20%3D%20%221px%20solid%20%23ccc%22%3B%20%0D%0A%20%20%20%20%2F%2FcreateDiv.style.background%20%3D%20%22%23f60%22%3B%20%0D%0A%20%20%20%20%2F%2FcreateDiv.style.height%20%3D%20%22200px%3B%22%3B%20%0D%0A%20%20%20%20var%20createText%20%3D%20document.createTextNode(%22%E6%88%91%E6%98%AF%E4%B8%80%E4%B8%AA%E5%B1%82%22)%3B%20%0D%0A%20%20%20%20createDiv.appendChild(createText)%3B%20%0D%0A%20%20%20%20var%20tlink%20%3D%20document.getElementById(%22tlink%22)%3B%20%0D%0A%20%20%20%20%2F%2Falert(tlink)%3B%20%0D%0A%20%20%20%20insertAfter(createDiv%2Ctlink)%3B%20%0D%0A%7D%20%0D%0Afunction%20insertAfter(newElement%2C%20targetElement)%20%7B%20%0D%0Avar%20parent%20%3D%20targetElement.parentNode%3B%20%0D%0Aif(parent.lastChild%20%3D%3D%20targetElement)%20%7B%20%0D%0Aparent.appendChild(newElement)%3B%20%0D%0A%7D%20else%20%7B%20%0D%0Aparent.insertBefore(newElement%2C%20targetElement.nextSibling)%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Awindow.onload%20%3D%20function()%7B%20%0D%0A%20%20%20%20tlink.onclick%3Dfunction()%20%0D%0A%20%20%20%20%7B%20%0D%0A%20%20%20%20cdiv()%3B%20%0D%0A%20%20%20%20%7D%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E"> </head> <body> <div id="tlink" style="cursor:pointer;">测试一下</div> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程