0
How to make a button do the inverse task after clicking one time in javascript?
For example making a button make the text bold , after first time clicking it should make the text not bold .
1 Réponse
+ 3
html
<span id="t">hey<span>
css
.t-bold{ font-weight: bolder }
js
document.query("#t").onclick = (e)=>{ e.target.classList.toggle('t-bold'); }
not tested, but you see what i trying to do.
by toggling the class that ulitize css to make a text bold