p.className=“message”和p.Attribute("class","message")有什么區(qū)別?二者分別用于什么情況!

冷冰風(fēng)
2015-05-18
2 回答
舉報(bào)
0/150
提交
取消
2015-09-08
有attribute()這個(gè)方法嗎?不是 setAttibue()? 和getAttributte()嗎?對(duì)于你的問(wèn)題? 我理解是這樣的element.setAttribute("class","")可以設(shè)置自定義的屬性?
?例如對(duì)于 <a>啊啊啊啊啊啊</a> 他有這些固有屬性 color? style? href? className? 那么用element.href element.color element.style? 可以設(shè)置它的屬性值 但是我設(shè)置這樣一個(gè)屬性element.aaaa?? 它就會(huì)報(bào)錯(cuò) undifined?? 但是用element.setAttribute("aaaa","自定義屬性");就不會(huì)報(bào)錯(cuò)
2015-05-18
沒(méi)有多大的區(qū)別 ? ??
兩個(gè)都是 ?添加屬性