第33页 向DOM中插入内容
- 章节名:向DOM中插入内容
- 页码:第33页
<!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <div id="node"> <p id="p1">Some</p> <p>fd</p> </div> <script type="text/javascript"> var pp=document.createElement("P");//createElement(),建立一个指定名称的元素。 pp.innerHTML="你好";//innerHTML,获取HTML当前标签的起始和结束里面的内容。 var abc=document.getElementById("node"); abc.insertBefore(pp,document.getElementById("p1"));//insertBefore(),可在已有的子节点前插入一个新的子节点。语法 :insertBefore(newchild,refchild) </script> </body> </html>
OIBIOI~鹿鸣对本书的所有笔记 · · · · · ·
-
第28页 HTML、CSS和JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/T...
-
第33页 向DOM中插入内容
说明 · · · · · ·
表示其中内容是对原文的摘抄