Jquery Click Event Not Firing On First Click, but does on second click, why?

前端 未结 4 1126
无人及你
无人及你 2021-02-15 15:20

I\'ve got a jQuery code, which

$("a.reply").click(function() {
//code
});

When I click the link with .reply class the fir

4条回答
  •  有刺的猬
    2021-02-15 15:50

    Does it still happen if you comment out all your code and simply have an alert("hi") inside the click function?

    Update

    I think Sarfaz has the right idea, but I would use the document ready function like so

    $(document).ready(function(){
      $("a.reply").click(function() {
        //code
      });
    });
    

提交回复
热议问题