innertextexample2.htm

来自「这是javascript高级程序设计的源码」· HTM 代码 · 共 24 行

HTM
24
字号
<html>
    <head>
        <title>InnerText Example</title>
        <style type="text/css">
            div.special {
                background-color: red;
                padding: 10px;
            }
        </style>
        <script type="text/javascript">
            function useInnerText() {
                var oDiv = document.getElementById("div1");
                oDiv.innerText = oDiv.innerText;
            }
        </script>
 
    </head>
    <body>
        <div id="div1" class="special"><b>Hello</b> world</div>
        <input type="button" value="Use InnerText" onclick="useInnerText()" />
        <p><strong>Note: </strong> Firefox does not support the <code>innerText</code> property so this example will fail.</p>
    </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?