$("body.specialPage") .closest("html") .css("background-color","");
The first line targets the body element with a special class. Then we select its parent HTML tag and βdeleteβ its background color. The beauty is that it will not select parent HTML unless the class is specifically configured for the one you are looking for.
This will also work:
if( $("body").hasClass("specialPage") ){ $("html").css("background-color",""); }
jQuery hasClass()
returns boolean ( true
if it has a class and false
if it is not), so the body tag has the class you are looking for, it will run the code in the if function, which again "removes" the background color from the tag HTML
Purag
source share