Jquery file format

Posted by sarbe on Stack Overflow See other posts from Stack Overflow or by sarbe
Published on 2011-03-10T07:45:09Z Indexed on 2011/03/10 8:10 UTC
Read the original article Hit count: 146

Filed under:

HI.

I have multiple webpages. So I have a common external js file. And I have added this js file to every page. I have multiple check boxes in every page. And I have written the click event in the external, common js file. But I wonder how the js file should be? Currently I have written like this.

$(document).ready(function() {
    $(".chk").click(function() {
    alert("hi");
   });
});

But whenever I click a checkbox the click event is fired twice. it should be once. I dont know where is the error, is there any error in writing the js file? please comment.

© Stack Overflow or respective owner

Related posts about jQuery