Link to home
Start Free TrialLog in
Avatar of Mark Branscum
Mark BranscumFlag for United States of America

asked on

Jquery if else not working ... WHY?

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");
      alert("Element not Found");


Open in new window

Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alex Puch
Alex Puch

You must use small letter in if instead of If
Avatar of Mark Branscum


lol seriously ..... Yep thats me old habits die hard .... I just couldnt see it for what ever reason .... thank you that was a fix
:) spot on my bad ,,, thanx for the fresh eyes
Glad to help.