change color by click event javascript

Solutions on MaxInterview for change color by click event javascript by the best coders in the world

showing results for - "change color by click event javascript"
Isabel
18 Jul 2020
1<script>
2
3    document.getElementById('change').onclick = changeColor;   
4
5    function changeColor() {
6        document.body.style.color = "purple";
7        return false;
8    }   
9
10</script>
Mercedes
26 Nov 2019
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
Nicolás
19 Feb 2019
1const btn = document.querySelector('button');
2
3function random(number) {
4  return Math.floor(Math.random() * (number+1));
5}
6
7btn.onclick = function() {
8  const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
9  document.body.style.backgroundColor = rndCol;
10}
queries leading to this page
how to make an event listener to change background colorhtml onclick color changechanging an element colour using onclickclick on element change colorhow to change color with every click in javascriptchange color in javascript handleclick change button color on click javascriptclick to change color javascriptadd eventlistenet to chnage in style of a domchange element color on click javascripthow to change the color of back ground on java script on click formhow to change placeholder color using javascriptjs change style of div in listenerwhen one of these elements is clicked 2c the text colour must change to blue javascripthow to write style in addeventlistenerchange text color when button is click jsonclick text color add javascriptchange textbox color javascriptonclick change the color of buttonhow to change the color of a button onclick event in javascriptchange button color onclick javascriptjs on click change colorchange text and color when button is click javascriptclick on button a change color of object javascriptjavascript function onclick to make color change reaactfunction js click change colorchange color on click javascriptjavascript onclick text color changeonclick change color of the text in javascriptjavascript button onclick change colorchange button color onclick using javascriptjavascript click to change colorjavascript event change stylejs change color on click with thishow to change button coloron click in javascripthtml change colour of text when on clickjavascript onclick change coloronclick button chnage the color of the consoole text in javascriptchange text color onclick javascriptjs button text changejs onclick change colorhow to change text color event listener javascripton click colour change button jshow to change text color on button click in javascriptjs change text color when clickedhow to change the color of a element onclick functionjavascript click change colorjavascript change color onclickchange element color onclickjavascript change color textchange style css with addeventlisteneronclick listener jsonclick change color input value javascriptjavascript click button change colorchange color when onclick javascriptjavascript button that changes color onclickchange style of event javascriptjavascript function onclick to make color change javascript change button color onclickonclick button change color exmaplechange color on click jschange element color on clickchange bg color onclick javascriptchange color of all text jsjavascript apply color on clickad evenet lsner js to change style cssschange div color on click javascriptonclick function change colourjavascript change font color on clickhtml inline javascript change color onclick eventhtml change color on clickbutton change color on click javascriptadd event listener style changejavascript addeventlistener style changeonclick change text color javascriptaddeventlistener js to change style 3cp onclick 3d 22myfunction 28this 2cred 29 22 3e click me to change my text colorchange css using javascript onclickonclick 3d 22changecolor 28 29 22js onclick color changechange style using elements eventon click java script change colorcolor button click event in javascripthow to color a text in javascriptjavascript onclick color changeonclick change color of buttononclick event change colorchange color by click javascripthow to change color of the text in html by button click in javascripthow to onclick change input tag color in javascriptonclick change this color in jsonclick change button colorchange text color on click with javascript change color of element onclickchange button text and background color with onclick eventaddeventlistener change styleon click change coloronclick color change in javascripthow to change the color of background on javascript on click formhow to change text color on click in csschnage text color in javascriptchange color of text when you click on it javascriptjavascirpt change text colro in a functionhow to change the color of text in onclickonclick change colorjs addeventlistener on specific background colorjavascript change color and text on clickchange color on click using getelementbyidjavascript click event change coloronclick change color in jsaddeventlistener css changechange background color javascript onclickclick color change javascriptjavascript change all text colorhow to change text color when clicked without javascriptchange text color on button click with javascripton click color change in anaddeventlistener stylejs btn color change by clickjs listen element change stylechange color that is not clicked javascriptjavascript change color of text on clickonclick change color cssjavascript change color on clickchange color on p element on click jsjs change text color after clicking on buttonhow to change button color after clicking javascriptchange text color when you click it in javascriptbutton change color en click js addeventlistner use event to change stylejavascript click element with colorjavascript change color of button onclickonclick color changehtml intext onclick change colorjavascript onclick color change of htmljavascript onclick change color w3schoolsbutton onclick change colorhow to update the color by button onclick in jschange color on click javascript and back to originalchange color on click with jsaddeventlistener 28 27change 27onclick to change colorhow change color on clickhow to make element change color onclickchange color of text when clicked button javascripthow to change text color js htmlhtml change color on click eventhow to change the text color using onclick in htmldom add text and color to a buttonchange color on button click javascriptonclick change text color cssif onclick event change colorchange color of element on clickchange button color onclick jshow to change color on button click in javascriptchange color in javascript onclickjavascript that changes color on clickchange color onclick javascriptjavascript onclick event change colorchange background color in javascript onclickchange color on click in javascriptin html onclick change colourchanging div color onclick javascriptjavascript on button click by id change colorjavascript button click change colorjavascript change text color on clickchange background color using javascript onclickchange color button onclickonclick change color jshow to change color on onclickget color with click event javascriptjs change text colrhow to change color of text inside button in javascriptjavascript button onclick color changeadd style event listener jshow to change a color of a text using onclick in htmlon click change color javascripton click change background color javascriptchange style through the eventonclick change this color in jsjavascript color change on clickjavascript change div color onclickonclick trigger event to change colorscript onclick change colorjs color change on clickhow to change the color using a text is clicked using javascript domjavascript onclick change color of divjs eventlistener style changechange html element color csslabel onclick jquery color changechange button color after click javascriptchange button color onclickhtml onclick change colorjs change color on clickchange style using element eventhow to change colors on click in jsjavascript change element style on eventon linck event colorchange color by click event javascriptchange color onclick javascrioptw3school change button color onclick javascriptjavascript addeventlistener changechange color onclickonclick button color changechange color on click domchange button onclickchange button text color on click jsclick button and change color javascriptchange color when clicked javascriptchange background color on click javascriptchange button color when clicked javascriptjavascript onclick button color changechange text field color javascriptfunction change color onclickjs change text color on clickchange color when clicked jsonclick color change javascriptonclick button change colorhow to change the color of a element on click functinonclick background color change in javascript w3schoolshow to change the color onclick using javascripthow to change color on click jshow to change the color of a element onclick function in javascriptclick change color jscolor change html on clickjavascript change element color on clickthis color change on click javascriptjavascript onclick change button colorselect color on div click jschange style addevent listener javascriptbutton onclick color changechange color when click javascripttext color change in jschange button text color javascriptchange the text color in javascriptjavascript modify color on clickbutton javascript on click change coloron button click color change using jsjavascript change text colorchange button color on click htmlonclick font color change in javascriptevent listener for chnage in style in domhtml in text onclick change coloronclick change color of that element cssjavascript click button to change color and do somethinginline javascript change color onclick eventhow to change color onclick function javascriptchange color on clickchange color onclick jsjavascript function change background color onclickhtml onclick event change colorjavascript button change color onclickchange button color in jshow to do change a background color with an event listeneronclick element change color cssjs make button change color on clickchange color javascript onclickonclick change colourchange color by click event javascript