惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
雷峰网
雷峰网
V
Visual Studio Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
IT之家
IT之家
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
月光博客
月光博客
A
About on SuperTechFans
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale

博客园 - JoyBin

使用CSS为图片添加更多趣味的5种方法. IT工作者要保护自己的头发啊.. document.execCommand()用法说明 用三层架构与设计模式思想部署企业级数据库业务系统开发(转) C#代码与javaScript函数的相互调用 IE6 png 透明 (三种解决方法)(转) - JoyBin 程序人生就像一场恶梦。 常用正则表达式 [转载]Meta标签详解 三级联动-完美版 - JoyBin - 博客园 asp.net(C#)服务器绝对路径转换成URL相对路径[修改] (转) flash的菜单与asp.net进行交互(转) 把生成的缩略图存到数据库中 母版页判断登陆 及 母版页与内容页的执行顺序 常用.net代码 常用JS代码 SQLServer存储过程分页 WMPLib.WindowsMediaPlayer 的用法 网页播放器 PlayState 的用法
添加html内容(insertAdjacentHTML和insertAdjacentText)
JoyBin · 2008-04-18 · via 博客园 - JoyBin

添加html内容(insertAdjacentHTML和insertAdjacentText)
     dhtml提供了两个方法来进行添加,insertAdjacentHTML和insertAdjacentText
insertAdjacentHTML方法:在指定的地方插入html标签语句。
     原型:insertAdjacentHTML(swhere,stext)
     参数:
     swhere:指定插入html标签语句的地方,有四种值可以用:
               1.beforeBegin:插入到标签开始前
               2.afterBegin:插入到标签开始标记后
               3.beforeEnd:插入到标签结束标记前
               4.afterEnd:插入到标签结束标记后
               stext:要插入的内容
       例:var sHTML="<input type=button onclick=" +      "go2()" + " value='Click Me'><BR>"
       var sScript='<SCRIPT DEFER>'
       sScript = sScript +      'function go2(){ alert("Hello from inserted script.") }'
       sScript = sScript + '</script' + '>';
       ScriptDiv.insertAdjacentHTML("afterBegin",sHTML + sScript);
       在html正文中加入一行:
     <DIV ID="ScriptDiv"></Div>
      最终变成:
     <DIV ID="ScriptDiv">
        <input type=button onclick=go2() value='Click Me'><BR>
        <SCRIPT DEFER>
          function go2(){alert("Hello from inserted sctipt.")}'
        </script>
      </DIV>
      insertAdjacentText方法与insertAdjacentHTML方法类似,只不过只能插入纯文本,参数相同