I'm trying to make a button that changes an already written text in a webpage. Changing the font style, weight etc | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm trying to make a button that changes an already written text in a webpage. Changing the font style, weight etc

Javascript html css

9th Sep 2019, 12:47 AM
Ojukwu Chiderah
Ojukwu Chiderah - avatar
2 Answers
+ 1
Set an on click to the button and change all you want to in the click function
9th Sep 2019, 12:53 AM
Qudusayo
Qudusayo - avatar
0
1. get your button element by id from html to your javascript, add an event listener with click event. 2. create a css class with your styles after click. 3. inside the callback in your event listener get the element that needs to change styles. 4. append the class name into the element that contains the text, use classList.add(‘.class’)
9th Sep 2019, 1:17 AM
Erick Ventura
Erick Ventura - avatar