Change logo image when I switch to a different language

I have this multilingual website. Is there a way I can change the logo.png to a different .png after I switch to “Chinese?”

I am using polylang plugin at the moment and this is what I have scrummed together:

$(function() {


if (pll_current_language == 'en') {
    $('.logo').css("background-image", "url(images/logo.png)");  
} else if (pll_current_language == 'zh') {
    $('.logo').css("background-image", "url(images/logo-CN.png)");  
} else {
    $('.logo').css("background-image", "url(images/logo.png)");  
}
});

Related posts

Leave a Reply

1 comment

  1. Changing

    if (pll_current_language == 'en') {
        $('.logo').css("background-image", "url(images/logo.png)");  
    } else if (pll_current_language == 'zh') {
        $('.logo').css("background-image", "url(images/logo-CN.png)");  
    } else {
        $('.logo').css("background-image", "url(images/logo.png)");  
    }
    

    to

    if (pll_current_language() == 'en') {
        $('.logo').css("background-image", "url(images/logo.png)");  
    } else if (pll_current_language() == 'zh') {
        $('.logo').css("background-image", "url(images/logo-CN.png)");  
    } else {
        $('.logo').css("background-image", "url(images/logo.png)");  
    }
    

    should work, you are missing the “()” after “pll_current_language”

    EDIT: Try this:

    $( document ).ready(function() {
    <?php
    if (pll_current_language() == 'en') {
    ?>
        $('.logo').css("background-image", "url(images/logo.png)");  
    <?php
    } else if (pll_current_language() == 'zh') {
    ?>
        $('.logo').css("background-image", "url(images/logo-CN.png)");  
    <?php
    } else {
    ?>
        $('.logo').css("background-image", "url(images/logo.png)");  
    <?php
    }
    ?>
    });