dom创建新节点的方法
1、//创建一个新节点
var pNode= document.createElement("p");
2、//创建文本
var pText= document.createTextNode("hello");
3、//将文本添加至创建的P节点中
pNode.appendChild(pText);
4、//将pNode节点添加到Body节点中
document.body.appendChild(pNode);
5、节点操作方法有,使用方法如上
appendChild()
removeClild()
replaceChild()
insertBefore()
1、jQuery中也有操作Dom节点的方法
//追加方法
$(".className").append("<b>你好!</b>"); //将B标签追加至节点中
2、$(".className").prepend("<b>你好!</b>"); //前置方法。insertBefore()
3、$(".className").after("<b>你好!</b>");
4、append()
appendTo()
prepen()
prepenTo()
after()
insertAfter()
before()
insertBefore()
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:128
阅读量:100
阅读量:69
阅读量:132
阅读量:120