addeventlistener js to change style

Solutions on MaxInterview for addeventlistener js to change style by the best coders in the world

showing results for - "addeventlistener js to change style"
Ana
18 Aug 2016
1var button = document.querySelector("button");
2
3button.addEventListener("click", function() {
4    const curColour = document.body.style.backgroundColor;
5
6    document.body.style.backgroundColor = curColour === 'red' ? 'blue' : 'red';
7});
8
Indigo
15 Nov 2018
1var button = document.querySelector("button");
2
3button.addEventListener("click", function() {
4    const curColour = document.body.style.backgroundColor;
5
6    if (curColour === 'red') {
7        document.body.style.backgroundColor = "blue";
8    }
9    else {
10        document.body.style.backgroundColor = "red";
11    }
12});
13
queries leading to this page
change style of event javascripthtml change color on click eventevent listener for chnage in style in domchange style through the eventjs listen element change stylechange style using element eventaddeventlistener js to change styleonclick listener jsjavascript click element with colorjs change style of div in listeneraddeventlistener javascript fucntionchange background color on click javascriptchange color on click javascript and back to originalchange style using elements eventhow to change the color of a button onclick event in javascripton button click color change using jsadd eventlistenet to chnage in style of a domaddeventlistener change stylead evenet lsner js to change style csssjs eventlistener style changehow to do change a background color with an event listenerjavascript addeventlistener style changejs addeventlistener wwhen classes change event listener jshow to write style in addeventlistenerjavascript change element style on eventadd style event listener jsaddeventlistener css changehow to make an event listener to change background coloraddeventlistener jsjs addeventlistener on specific background color addeventlistener 28 27input 27change color in javascript onclickjavascript modify color on clickaddeventlistener styleaddeventlistner use event to change stylechange style addevent listener javascriptjavascript addeventlistener changechange color on click jsget color with click event javascriptevent listener in javascriptjavascript event change styleaddeventlistener 28 27change 27add event listener style changechange style css with addeventlistenerchange color on click using getelementbyidaddeventlistener js to change style