Javascript , event handler is always called, even if the event is not raised

前端 未结 2 1252
悲哀的现实
悲哀的现实 2020-12-22 10:22

i have the following code which extends the JQuery and adds a method to the JQuery:

$.fn.attachWithMessage = function () {
  $(this).focusin(showMessage());
         


        
2条回答
  •  青春惊慌失措
    2020-12-22 10:43

    just remove the parenthesis

    $(this).focusin(showMessage());
    

    should be

    $(this).focusin(showMessage);
    

    Hope this helps

提交回复
热议问题