admin管理员组

文章数量:1389772

How can i change the background color of the body by using the developer console of my browser? I tried it with: document.body.style.backgroundColor('black');

and document.body.style.backgroundColor=black;

But nothing worked.

How can i change the background color of the body by using the developer console of my browser? I tried it with: document.body.style.backgroundColor('black');

and document.body.style.backgroundColor=black;

But nothing worked.

Share Improve this question edited May 20, 2016 at 1:14 Black asked May 20, 2016 at 1:06 BlackBlack 20.5k46 gold badges188 silver badges296 bronze badges 4
  • 4 document.body.style.backgroundColor='black' works but backgroundColor('black'); is not correct because it's not a function – Madhawa Priyashantha Commented May 20, 2016 at 1:08
  • Oh, i actually used black instead of 'black' -.- thank you! – Black Commented May 20, 2016 at 1:09
  • 1 jsfiddle/pz0tb427 – Madhawa Priyashantha Commented May 20, 2016 at 1:11
  • wow, im definitely tired... i mean i used document.body.style.backgroundColor=black; after using quotes it is working, thank you so much guys. – Black Commented May 20, 2016 at 1:13
Add a ment  | 

1 Answer 1

Reset to default 6
document.body.style.backgroundColor = "black";

本文标签: javascriptChange background color of body with consoleStack Overflow