Alegro
Alegro

Reputation: 7956

jquery to check If a div has a specific content

$("#thinker01").click( function() {
$("#info").html("323");
    if ($("#info").html == "323"){  //doesn't work - how to say this?
        $("#imgOk").fadeIn();
    }
});

Without if - the fourth line works.

Upvotes: 0

Views: 52

Answers (2)

Denys Séguret
Denys Séguret

Reputation: 382102

html is a function and must be called.

You may use this :

if ($("#info").html() == "323")

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

if ($("#info").html() == "323")

Notice the () around the html function which is what is actually invoking it. Otherwise you are using it as a property and there's no such property.

Upvotes: 3

Related Questions