Anmol Ratan Mohla Anmol Ratan Mohla - 7 months ago 26
jQuery Question

How i remove another class from my header section for inner page

I make a project in wordpress. I used a conman class for header section called "header" but only for home page i used another class "home-header with header". i.e.

<header class="header home-header">
<div class="container">
<div class="logo"><a href="index.html"><img src="<?php bloginfo('template_directory'); ?>/images/logo.png" alt=""></a></div>
<div class="connect">
<label><img src="<?php bloginfo('template_directory'); ?>/images/small-phone-icon.png" alt="">(540) 455-5057</label>
<label><img src="<?php bloginfo('template_directory'); ?>/images/small-mail-icon.png" alt=""><a href=""></a></label>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'menu_id' => 'primary-menu' ) ); ?>

My question is how i remove home-header class from inner pages the home-header class not for inner pages?

class header is default for the site.

Please help my....


on wordpress, usualy on the first page , the .body has class .home or something specific for the first page

if you already gave <header> the class home-header in the html

use this jsfiddle 1

if (!$("body").hasClass("home")) {

the ! means not so you read it like if header hasNOTclass home

if you want to give the header classes only from JQ .

use this : jsfiddle

if ($("body").hasClass("home")) {

or if your <header> has class header and you want to add a class only for first page. use the code below :

$("body.home header").addClass("home-header")