This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12083|Reply: 2

[JavaScript] The difference between innerHTML and innerText

[Copy link]
Posted on 5/22/2015 3:13:08 PM | | |
The former will display the changed style, while the latter will only display the text

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head runat="server">
  4.     <title>武软论坛</title>
  5.     <scrip去掉t type="text/javascrip去掉t">
  6.         function test() {
  7.             var a=document.getElementById("lab").innerHTML;
  8.             alert(a);
  9.         }
  10.         function test2() {
  11.             var b = document.getElementById("lab").innerText;
  12.             alert(b);
  13.         }
  14.     </scrip去掉t>
  15. </head>
  16. <body>
  17.     <form id="form1" runat="server">
  18.     <div>
  19.         <label id="lab"><span>123</span></label>
  20.         <input id="Button1" type="button" value="确定" onclick="test2()" />
  21.     </div>
  22.     </form>
  23. </body>
  24. </html>
Copy code






Previous:html javascrip remove t to make 9 times 9 published (99 multiplication table)
Next:asp.net the standard three-tier framework used for the exam
Posted on 5/22/2015 10:29:07 PM |
The teacher said that it was useless to know this
Posted on 5/22/2015 10:32:29 PM |
Long knowledge                     
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com