Jquery if else not working ... WHY?

Mark Branscum
Mark Branscum used Ask the Experts™
on
got an error saying unexpected token else ...... am I missing a " ; " somewhere? or something?

<button id="btn">Click Me</button>

Open in new window

$(document).ready(function() {
  $("#btn").click(function() {

    If($("#btn").length > 0) {
      alert("Element Found");
    }
    else 
    {
      alert("Element not Found");
    }

  });
});

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Lead Software Engineer
Commented:
You have the I in If capitalized. Make it lowercase.
You must use small letter in if instead of If
Mark BranscumWeb Developer

Author

Commented:
lol seriously ..... Yep thats me old habits die hard .... I just couldnt see it for what ever reason .... thank you that was a fix
Mark BranscumWeb Developer

Author

Commented:
:) spot on my bad ,,, thanx for the fresh eyes
Shaun KlineLead Software Engineer

Commented:
Glad to help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial