Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

onclick change text color javascript

<script>

    document.getElementById('change').onclick = changeColor;   

    function changeColor() {
        document.body.style.color = "purple";
        return false;
    }   

</script>
Comment

javascript change color of button

document.getElementById("button").style.background='#000000';
Comment

change the button color on click

button:active{
  background-color:green;
}
Comment

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.style.backgroundColor = rndCol;
}
Comment

to change color on button click

function btnRed() {
  document.getElementById("Div1").style.backgroundColor="Red";
}
function btnGreen() {
  document.getElementById("Div2").style.backgroundColor="Green";
}
function btnBlue() {
  document.getElementById("Div3").style.backgroundColor="Blue";
}
function btnReset() {
  document.getElementById("Div1").style.backgroundColor="Black";
  document.getElementById("Div2").style.backgroundColor="white";
  document.getElementById("Div3").style.backgroundColor="white";
}
Comment

change-button-color-onclick

const btn = document.getElementById('btn');

let index = 0;

const colors = ['salmon', 'green', 'blue', 'purple'];

btn.addEventListener('click', function onClick() {
  btn.style.backgroundColor = colors[index];
  btn.style.color = 'white';

  index = index >= colors.length - 1 ? 0 : index + 1;
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: SHOPIFY CUSTOMER WITHOUT REGISTRATION 
Javascript :: how to say "and not" in javascript 
Javascript :: c# to json online 
Javascript :: What can I put in the parentheses of an if statement to make it false 
Javascript :: set npm push proxy 
Javascript :: fade animation vuetify js 
Javascript :: create extern to be usable in c# 
Javascript :: how to make your own version of filter method 
Javascript :: nextjs update ui when data is updated 
Javascript :: public url react for serving django static in production 
Javascript :: &amp;&amp; in javascript new 
Javascript :: convert todays date to json datetime 
Javascript :: currentContract.transferFrom is not a function 
Javascript :: MongoDB Express Find All In Database 
Javascript :: How to switch to a remote git branch that does not exist locally 
Javascript :: odoo owl usestate 
Javascript :: _.clone underscore 
Javascript :: nodejs express parse query params boolean 
Javascript :: Using strings, the spread operator creates an array with each char in the string 
Javascript :: react axios POST with super constructor parent class 
Javascript :: unreachable code detected javascript 
Javascript :: Shopify cart context 
Javascript :: pass prop through route 
Javascript :: lwc reduceErrors showtoast 
Javascript :: React clock via props 
Javascript :: VM1658:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 
Javascript :: find the minimum number in an array javascript 
Javascript :: javascript detect if active element is writable 
Javascript :: how to add defer attribute using js 
Javascript :: ohif add auth to config 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =