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 .

2nd Mar 2020, 4:57 PM
Amin Al
Amin Al - avatar
1 Answer
+ 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
2nd Mar 2020, 5:01 PM
Taste
Taste - avatar