第一
<div
id="div"><input name="button" value="Button"
type="button"><font color="green"><h2>This is a
DIV!</h2></font></div>
<input name="innerHTML" value="innerHTML" type="button"
OnClick="alert(div.innerHTML);">
<input name="outerHTML" value="outerHTML" type="button"
OnClick="alert(div.outerHTML);">
<input name="innerText" value="innerText" type="button"
OnClick="alert(div.innerText);">
<input name="outerText" value="outerText" type="button"
OnClick="alert(div.outerText);">
第二
innerHTML,和outerHTML好像都能动态改变网页内容,他们有什么区别吗
---------------------------------------------------------------
举个例子:
<span id=a><b>aa</b></span>
document.all.a.innerHTML == "<b>aa</b>" //不包括标签自身
document.all.a.outerHTML == "<span id=a><b>aa</b></span>" //包括标签自已
<div
id="div"><input name="button" value="Button"
type="button"><font color="green"><h2>This is a
DIV!</h2></font></div>
<input name="innerHTML" value="innerHTML" type="button"
OnClick="alert(div.innerHTML);">
<input name="outerHTML" value="outerHTML" type="button"
OnClick="alert(div.outerHTML);">
<input name="innerText" value="innerText" type="button"
OnClick="alert(div.innerText);">
<input name="outerText" value="outerText" type="button"
OnClick="alert(div.outerText);">
第二
innerHTML,和outerHTML好像都能动态改变网页内容,他们有什么区别吗
---------------------------------------------------------------
举个例子:
<span id=a><b>aa</b></span>
document.all.a.innerHTML == "<b>aa</b>" //不包括标签自身
document.all.a.outerHTML == "<span id=a><b>aa</b></span>" //包括标签自已