运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body onkeydown="myFunction(event)"> <h1>The Document Object</h1> <h2>The execCommand() Method</h2> <p>The executeCommand() method executes a specified command on selected text.</p> <p>Select some text in this page, and press SHIFT to make the selected text toggle between bold and normal.</p> <script> document.designMode = "on"; function myFunction(event) { if (event.keyCode == 16) { // Execute command if user presses the SHIFT button: document.execCommand("bold"); } } </script> </body> </html>