Help with if statement

Help with if statement

Why doesn't this embedded if statement work?

   
var subscribeState = "off";
    /*hover*/$('#subscribe').hover(function() {
        if(subscribeState == "off") {
    $(this).attr("src", "images/btn_Subscribe_over.gif"); alert(subscribeState);
    }, function() {
        $(this).attr("src", "images/videos_subscribe_btn.jpg"); alert(subscribeState);
         }
    });


but this does work:

var subscribeState = "off";
    /*hover*/$('#subscribe').hover(function() {
        $(this).attr("src", "images/btn_Subscribe_over.gif");
    }, function() {
        $(this).attr("src", "images/videos_subscribe_btn.jpg");
    });


Thanks.[/code]
    • Topic Participants

    • jenni