innerHTML和outerHTML有什么區(qū)別
一威恼、區(qū)別:
1)innerHTML:
從對(duì)象的起始位置到終止位置的全部?jī)?nèi)容,不包括Html標(biāo)簽。
2)outerHTML:
除了包含innerHTML的全部?jī)?nèi)容外, 還包含對(duì)象標(biāo)簽本身介蛉。
二、例子:
<div id="test">
?? <span style="color:red">test1</span>
?? test2
</div>
1溶褪、innerHTML的值是“<span style="color:red">test1</span> test2 ”
2、outerHTML的值是<div id="test"><span style="color:red">test1</span> test2</div>