编辑下面的代码:【加编码】
<html> <body id="w3s" text="#0000FF"> <script> document.write("The text color is: ") document.write(document.getElementById("w3s").text); </script> <p><b>Note:</b> Internet Explorer always returns the colors in hex, while most other browsers returns the attribute value.</p> <p><b>Note:</b> If using color names, different browsers may render different colors, and Firefox have problems if the attribute value is in RGB code (will not display correct color).</p> <p><b>Tip:</b> To produce equal results in all browsers, always use hex code to specify colors.</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂