fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p id="myP" contenteditable="true">尝试修改文本。</p> <button onclick="myFunction(this);">禁用文本可编辑!</button> <p id="demo"></p> <script> function myFunction(button) { var x = document.getElementById("myP"); if (x.contentEditable == "true") { x.contentEditable = "false"; button.innerHTML = "启用 p 元素内容编辑!"; } else { x.contentEditable = "true"; button.innerHTML = "禁用 p 元素内容编辑!"; } } </script> </body> </html>
运行结果