0

I've looked on the forum and my question is a duplicate of Button click event not firing in jQuery, except my code already matches the given answer.

I've stripped this down for you guys anyway, and can confirm that links with a class of disabled do not fire, so this proves the document ready and Jquery library are correct.

Javascript

$(document).ready(function () {
  // Prevents links from firing
  $('a.disabled').click(function (e) {
    e.preventDefault();
  });

  // Handles search
  $("#btnTreeSearch").click(function () {
    alert("click search fool!");
  });
});

Html

<input type="submit" value="btnTreeSearch" />

Any clues?

1
  • 1
    Your input doesn't have the id you are referencing Commented Jan 18, 2013 at 15:56

2 Answers 2

7

You need to assign id to input to use id selector

Live Demo

Html

<input type="submit" id="btnTreeSearch" value="btnTreeSearch" />

Javascript

 $("#btnTreeSearch").click(function () {
     alert("click search!");
 });
Sign up to request clarification or add additional context in comments.

1 Comment

Oops, just i just relaised what an idiot i am. I raced back here but wasn't as quick as you. The end of a long day!
1

Change value="btnTreeSearch" to id="btnTreeSearch".

1 Comment

Oops, just i just realised what an idiot i am. I raced back here but wasn't as quick as you. The end of a long day!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.