What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-02 07:55:02
style.backgroundcolor
// change background color for specific id .. function changebackground(){ document.getElementById('id').style.backgroundColor = 'green' ; } // change background color for whole body.. function changebackground(){ document.body.style.backgroundColor =... Add solution -
Other 2022-02-21 13:40:11
javascript-change color onclick()
const btn = document.querySelector('button'); function random(number) { return Math.floor(Math.random() * (number+1)); } btn.onclick = function() { const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')'; document.body.st... Add solution -
Javascript 2022-01-22 19:41:14
addeventlistener js to change style
var button = document.querySelector("button"); button.addEventListener("click", function() { const curColour = document.body.style.backgroundColor; document.body.style.backgroundColor = curColour === 'red' ? 'blue' : 'red'; }); Add solution -
Javascript 2021-11-19 12:58:28
javascript style background color
// change background color for specific id .. function changebackground(){ document.getElementById('id').style.backgroundColor = 'green' ; } // change background color for whole body.. function changebackground(){ document.body.style.backgroundColor =... Add solution -
Javascript 2021-11-06 03:53:13
change color of css in js
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Change the Background Color with JavaScript</title> <script> // Function to change webpage background color functio... Add solution -
Javascript 2021-10-11 12:31:07
random rgba color javascript except black
function random_bg_color() { var x = Math.floor(Math.random() * 256); var y = 100+ Math.floor(Math.random() * 256); var z = 50+ Math.floor(Math.random() * 256); var bgColor = "rgb(" + x + "," + y + "," + z + &... Add solution