Why does click event handler fire immediately upon page load?

前端 未结 4 845
一整个雨季
一整个雨季 2020-11-21 06:50

I playing around with a function that I want to bind to all the links. At the present the function fires when the page loads, instead of when I click on the link.

H

4条回答
  •  借酒劲吻你
    2020-11-21 07:36

    Use the below line. showDiv() will call the function rigth away when that line is executed.

    $('a.test').bind("click", showDiv);
    

提交回复
热议问题