outertextexample2.htm

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

HTM
26
字号
<html>
    <head>
        <title>OuterText Example</title>
        <style type="text/css">
            div.special {
                background-color: red;
                padding: 10px;
            }
        </style>
        <script type="text/javascript">
            function useOuterText() {
                var oDiv = document.getElementById("div1");
                oDiv.outerText = oDiv.outerText;
                alert(document.getElementById("div1"));
            }
        </script>
 
    </head>
    <body>
        <div id="div1" class="special">This is my original text</div>
        <input type="button" value="Use OuterText" onclick="useOuterText()" />
        <p><strong>Note: </strong> Firefox does not support the <code>outerText</code> property so this example will fail.</p>

    </body>
</html>

⌨️ 快捷键说明

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