Search code examples
jqueryjoomla

Change logo on a specific page class


I work with Joomla and I want to change the logo image source on a specific body class.

So when I have

<body class="itemid-131">

the src here:

<img class="sp-default-logo" src="images/logo.png">

to be:

<img class="sp-default-logo" src="images/logo-white.png">

Thank you


Solution

  • You can simply do this (i replaced the body with a div just for the example) :

    $(document).ready(function() {
      $('.itemid-131 .sp-default-logo').attr('src', 'images/logo-white.png');
    
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="itemid-131">
      <img class="sp-default-logo" src="images/logo.png">
    </div>