源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <script> function displayResult() { alert(document.getElementById("p1").style.cssText); } </script> </head> <body> <p id="p1" style="border:2px dashed green;color:red;">This is a paragraph.</p> <br> <button type="button" onclick="displayResult()">Get the style declaration as a string</button> </body> </html>
运行结果: