How to make a script for a button?
-
When you click on the button, the text inside the button should become bold.
Runtime
JavaScript Joseph Lin, Nov 11, 2020 -
Change styles by class,
Use elem.classList.toggle ('bold'); to switch classes.
https://codepen.io/golfalfasierra/pen/QWEyryZJoseph Mullins -
.bold{
font-weight: bold;
}
function buttonClick(){
var elem = document.getElementById('bold');
elem.classList.add("bold");
}Anonymous -
https://jsfiddle.net/litdon/8g4rc601/10/Anonymous
3 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!