innerHTML和innerText的区别:

innerHTML和innerText的区别:

< div style= " width : 100 px ; height : 100 px ; background-color : lightskyblue " id= "div1" class= "div" title= "123" >
zzzzzzzz
< a href= "#" > 连接 a >
div >
< a href= "" type= "typea" id= "a1" title= "345" index= "1" add= "2" > 百度一下 a >

console. log( div1. innerHTML);
console. log( div1. innerText);
innerHTML会获得当前元素所有的属性操作(div的所有)
innderText只会获得div和a标签里面的类容
var arr = div1 . attributes ;
是把所有的元素打印出来放在数组里






console . log ( div1 . style ); //样式
console . log ( div1 . id ); //id值
console . log ( div1 . className ); //class值
console . log ( div1 . title ); //title值

你可能感兴趣的:(html)