Barrie Reader
Barrie Reader

Reputation: 10713

What is wrong with this javascript

ARGH! What's wrong with this??

$(document).ready(function() {
  var monkeyTrouble = $('#monkeyTrouble').attr('rel');
  if (monkeyTrouble = "banana") {
    alert("oooh oooh ahh ahhh");
  }
});

Upvotes: -1

Views: 73

Answers (4)

Marin
Marin

Reputation: 1321

well, if statement should be

if (monkeyTrouble == "banana")

note the "==".

Upvotes: 1

jensgram
jensgram

Reputation: 31508

  if (monkeyTrouble == "banana") {

Comparing vs. assigning.

Upvotes: 1

Ryano
Ryano

Reputation: 2120

Think you are looking for this...

if (monkeyTrouble == "banana") {

Hope that helps!

Upvotes: 6

Kobi
Kobi

Reputation: 138007

The condition is using =, should probably be ==:

if (monkeyTrouble == "banana")

Upvotes: 3

Related Questions