Jquery function to compare background image of button when button click

Jquery function to compare background image of button when button click

BY 01 Jul 2015 Web Application Development

Hi,

I want to comape background image of button when button click,my code is

*********************************************************

js file

$(document).ready(function() {

    $(“#mt1”).click(function() {
        if (document.getElementById(“mt1”).style.backgroundImage === “url(‘images/cmst1.png’)”)
            {
            
            alert(“hello world”);
            }
        
    });

******************************************************

css file

.imghr
{
    background:transparent;    
    background-image:url(‘images/cmst1.png’);

    height:20px;
    width:120px;
    background-repeat: no-repeat;    
    border:none;
    outline:none;
    display:block;
   margin-top:10px;
   text-align:center;
}

**************************************

Html file

<button type=”button” id=”mt1″ class=”imghr”></button>

 

*******************************************

my code does not give me what i want,please help me as soon as possible.

 

thanks in advance

Thanks and regards

Mohit Kumar

 

 

 

Written by