Usage: SupeSite/X-Space official site % x-ZP $ k? 'Dwz _{
SupeSite/X-Space official site K? _/T9s3 ^ QJ a4X
<Div id = "test">
-Od. \ k] d/A & | 0 <span style = "color: red"> test1 </span> test2 SupeSite/X-Space official site Tw? UY4Z A + scv' u; y
</Div> SupeSite/X-Space official site # G }*~ 2_D? M
Nt & {8u: Y {0 can be used in JS: SupeSite/X-Space official site Y7dj9Yb, K & x. xv #{
SupeSite/X-Space official site! R \ TS /~, ^ N
Test. innerHTML:
That is, all content from the starting position of the object to the ending position, including Html tags.
In the preceding example, the value of test. innerHTML is "<span style =" color: red "> test1 </span> test2 ".
GXI; d % [) kmA0SupeSite/X-Space official site % ~ : M: L6BX9Tq} x'
Test. innerText:
Content from the starting position to the ending position, but it removes the Html Tag
In the preceding example, the value of text. innerTest is "test1 test2", in which the span tag is removed.
Test. outerHTML:
In addition to all the content of innerHTML, it also contains the object tag itself.
In the preceding example, the value of text. outerHTML is <div id = "test"> <span style = "color: red"> test1 </span> test2 </div>.
QG ~ X # complete example of vrh % ^ * G0:
<Div id = "test"> SupeSite/X-Space official site k9p5Y1I: Y u7U-l f
<Span style = "color: red"> test1 </span> test2
K {a) Ea8Zc0 </div>
; Z _ zfM1sv0
/W: kb (F! J'3d3 ~ Vt0 <a href = "javas Syntax: alert (test. innerHTML)"> innerHTML content </a>
Yj0qp "ZF % f6 ~ 0 <a href = "javas Syntax: alert (test. innerText)"> inerHTML content </a>
1P3k, Ns ^ B $ pp0 <a href = "javas Syntax: alert (test. outerHTML)"> outerHTML content </a>
-\ 1T8 ^ "^-V | & [6 \. k7r0SupeSite/X-Space official site 0f & z * ZE | W
Note:
InnerHTML is a W3C standard attribute, while innerText is only applicable to IE browsers. Therefore, use innerHTML as much as possible, instead of innerText. If you want to output content without HTML tags, you can use innerHTML to obtain the content containing HTML tags and use regular expressions to remove HTML tags. The following is a simple W3C-compliant example: supeSite/X-Space official site * Dh % t-\ SZ
''D + \ 9hZp & s5? V0 <a href = "javas Syntax: alert (document. getElementById ('test'). innerHTML. replace (/<. +?> /Gim, '')"> no html, compliant with W3C standards </a>