当前第2页 返回上一页
三、文档结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | parentNode
childNodes
firstChild
lastChild
nextSibling
previoursSibling
nodeType
nodeVlue
nodeName
firstElementChild
lastElementChild
nextElementSibling
previousElementSibling
childElementCount
|
四、javascript操作DOM
1 2 3 4 5 | document.getElementById( "img1" ).alt;
document.getElementById( "img1" ).src= "" ;
document.getElementById( "img1" ).setAttribute( "src" , "1small.jpg" );
document.getElementById( "img1" ).getAttribute( "class" );
document.getElementsByClassName( "cnblogs_code" )[0].attributes;
|
五、元素内容及节点创建
1 2 3 4 5 6 7 8 9 10 | innerText、textContent
innerHTML
document.createTextNode( "<p>我是一个javascript新建的节点</p>" );
document.createElement( "p" );
appendChild();
insertBefore();
removeChild();
replaceChild();
cloneNode();
document.getElementById( "div1" ).style.backgroundColor= "#fff" ;
|
相关学习推荐:javascript视频教程
以上就是JavaScript操作DOM的方法有哪些?的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
javascript弹出框有哪些
javascript怎么移除属性
javascript如何显示和隐藏div
javascript如何定义变量
快速了解ui组件功能设计
javascript中删除数组元素的方法有哪些
javascript异步加载的详细介绍(附代码)
javascript怎么删除li
怎么使用javascript将对象转为字符串
typescript基础类型以及与javascript对比讲解
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » JavaScript操作DOM的方法有哪些?