1 // change background color for specific id ..
2function changebackground(){
3 document.getElementById('id').style.backgroundColor = 'green' ;
4}
5// change background color for whole body..
6function changebackground(){
7 document.body.style.backgroundColor = 'green';
8}
9
1function changeBackground(color) {
2 document.body.style.background = color;
3}
4
5window.addEventListener("load",function() { changeBackground('red') });
1function btn() {
2 event.stopPropagation();
3 }
4
5 var button = document.getElementById("btn");
6 button.addEventListener("click", function (e) {
7 e.target.style.backgroundColor = "green";
8 });
9 button.addEventListener("focusout", function (e) {
10 e.target.style.backgroundColor = "";
11 });