jack.cap.rooney
jack.cap.rooney

Reputation: 1306

jQuery not firing click events for button in IE

I'm a newbie of jQuery. Now I'm trying to intercept click login button that I've create with id='btnL' with this code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 

<script type="text/javascript">

(function() {
    $("#btnL").click(function() {
        alert("Handler for .click() called.");
    });
})();

</script>

I've put this code inside a body but i don't know why it works correctly on FireFox and Chrome, but it not works fine in Internet Explorer. How can i solve it? which is the problem?

Thanks

Upvotes: 0

Views: 1844

Answers (3)

WuHoUnited
WuHoUnited

Reputation: 8429

There are 2 problems.

You should have

$(document).ready(function() {
        $("#btnL").click(function() {
            alert("Handler for .click() called.");
        });
    });

like the others say but also in your URL for the Google API. You have 3 backslashes when you should have 2.

Upvotes: 1

Shyju
Shyju

Reputation: 218762

You are missing $ at the beginning. This should work.

  $(function() {
        $("#btnL").click(function() {
            alert("Handler for .click() called.");
        });
    });

Here is the working sample : http://jsfiddle.net/ftfaF/

Upvotes: 3

ianaldo21
ianaldo21

Reputation: 669

You don't seem to have a $ at the start of your function, $(function ... not sure if that is the problem without testing it, as I'm on my phone writing this answer.

Upvotes: 1

Related Questions