How to find all h1 and add a class to it using Jquery

Forums jQueryHow to find all h1 and add a class to it using Jquery
Staff asked 7 months ago

I have to find all h1 tags in a html page and add a class which has color red to them

My class is ass follows:

.error{

color:red;

}

jQuery(‘h1’).addClass(“error”);

Tarun Thummar replied 2 months ago

Answers (1)

Add Answer
Tarun Thummar Marked As Accepted
Staff answered 7 months ago

You can use Below code.

jQuery('h1').addClass('error');

 

You can use Below code

$(“body”).find(“h1”).addClass(‘error’)

Kathiriya Pritam replied 2 months ago

Subscribe

Select Categories