JSFiddle - React, Tailwind, and code Playground

HTML

<img class="img2" src="https://ssl.gstatic.com/accounts/services/mail/buttons/apple_store_en.png" />

JavaScript

$(document).ready(function () {
     var open=true;    
    $('.img2').click(function () {
        
      
        $(this).attr('src', function (i, oldSrc) {
            return oldSrc == 'https://ssl.gstatic.com/accounts/services/mail/buttons/apple_store_en.png' ? 'https://ssl.gstatic.com/accounts/services/mail/buttons/google_play_en.png' : 'https://ssl.gstatic.com/accounts/services/mail/buttons/apple_store_en.png';
        });
        
        if(open==true)
       {
alert("hi"); 
           open=false;
       }
       else
       {
alert("hey"); 
            open=true;
        }
});
    });