编辑下面的代码:【加编码】
<html> <body> <p id="myP">这是个段落,点击按钮使该段落可编辑。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myP").contentEditable = true; document.getElementById("demo").innerHTML = "以上 p 元素现在可编辑,尝试修改文本。"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂