当前第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怎么设置背景颜色
介绍js的四种类型检测方法及根据jquery写的工具方法
javascript的this使用方法有哪些
javascript如何实现异步
javascript实现小型区块链的方法介绍(附代码)
javascript属于哪种语言类型
如何理解javascript原型链
javascript字符串如何替换元素
javascript创建新节点方法是什么
如何使用canvas画一个微笑的表情(代码示例)
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » JavaScript操作DOM的方法有哪些?