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';
});
var button = document.querySelector("button");
button.addEventListener("click", function() {
const curColour = document.body.style.backgroundColor;
if (curColour === 'red') {
document.body.style.backgroundColor = "blue";
}
else {
document.body.style.backgroundColor = "red";
}
});
Also in JavaScript:
- js detect mobile
- timeout httppost angular
- javascript bind multiple arguments
- adding jquery to vuepress
- key value json javascript
- js if char in string
- split string javascript
- remove curly brackets from stringify javascript
- how get parent element javascript
- count number of checkboxes in html jquery
- javascript add value to input
- javascript program german to english translation
- generator in classs js
- javascript capitalize words
- js invert color
- how to add tooltip in angular for multiple items in an object
- calculate log in javascript
- set auto width sheetjs
- how to compare strings in javascript ignoring case sensitive
- javascript array group by id
- sum array without loop javascript
- stopwatch with javascript
- set attribute javascript background image
- js find place value