要在JavaScript中返回背景色,请使用backgroundColor属性。它允许您返回背景颜色。
您可以尝试运行以下代码,以了解如何使用JavaScript返回元素的背景色-
<!DOCTYPE html> <html> <body> <button onclick="display()">Click to Set background Color</button> <script> function display() { document.body.style.backgroundColor = "blue"; } </script> </body> </html>