We can dynamically add class to the html using the jQuery.
It is used when we are adding html dynamically or when at an event we want that css to be called.
We can add the css class simply
$("button").click(function(){
$("h1,p,a,span").addClass("red")
});
We can also remove the class by simply using function.
$(".add").click(function(){
$("h1, p, a, span").removeClass("grey")
});
Instead of giving the button we can also give the id or class like in remove function.
We can also change the event like for click we can use keyUp.
0 Comment(s)