编辑下面的代码:【加编码】
<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>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂