zoukankan      html  css  js  c++  java
  • innerHTML、outerHTML、innerText、outerText的区别

    1.innerHTML Sets or retrieves the HTML between the start and end tags of the object;
    2.outerHTML Sets or retrieves the object and its content in HTML;
    3.innerText Sets or retrieves the text between the start and end tags of the object;
    4.outerText Sets or retrieves the text of the object.

    <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);">


    运行一下上面的代码就知道区别的所在了^_^

  • 相关阅读:
    雑談
    safari下无法模拟click()的解决方法 ------转载
    用户操作
    居中
    replace 重写
    JS数组添加元素的三种方式
    Asp.Net Core 包
    CSS3 动画 可以参考
    CSS3 动画
    完全居中
  • 原文地址:https://www.cnblogs.com/Dicky/p/125973.html
Copyright © 2011-2022 走看看