JS的dom获取innerHtml和innerText的区别
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>JSDom获取图层节点</title></head><body><script type="text/javascript"> function getInnerHtml() { var dom=document.getElementById("div1"); dom.innerHTML="<h1><font color=‘red‘>这是getInnerHtml</font></h1>"; } function getInnerText() { var dom1=document.getElementById("div2"); dom1.innerText="<h1><font color=‘red‘>这是getInnerHtml</font></h1>"; }</script><input type="button" value="innerHtml" onclick="getInnerHtml()"><div id="div1"></div><br><input type="button" value="innerText" onclick="getInnerText()"><div id="div2"></div></body></html>
相关推荐
WebVincent 2019-11-17
MrWhite0 2015-03-17
srchange 2016-04-26
htmlman0 2019-04-03
DolphinThinker 2019-06-29
kbkiss 2019-06-29
zwq 2016-04-26
WCschool官方 2015-07-20
lzn 2015-06-10
XaverSun 2015-03-17
sunnylinner 2014-12-19
yaoliuwei 2014-09-25
zhangpeng 2014-09-05
来老师 2014-08-10
zhangpeng 2014-05-04
XaverSun 2013-11-15
careyourself 2013-11-15
maozhuofan 2019-06-18
tianqi 2013-07-23