How to use java script for front end changes

0
For example: I want to apply CSS on screen text on the click of a button by using java Script function.
asked
1 answers
1

Give the text or container a (unique) class, then target it to change style or add/remove classes with classList:

 

// set color red
document.getElementsByClassName('yourclass')[0].style.color = "red";

// add class text-danger (assuming you have that and it makes text also red)
document.getElementsByClassName('yourclass')[0].classList.add("text-danger");

 

Or toggle a boolean or something in a dataview object and use dynamic classes.

answered