jQuery .on() method - passing argument to event handler function

前端 未结 6 1392
别那么骄傲
别那么骄傲 2021-01-31 07:49

I have the following script which does not work



        
6条回答
  •  旧巷少年郎
    2021-01-31 08:31

    The .on() function expects a function reference to be passed; what you're doing is calling the function and passing its return value. If you need to pass a parameter you'll need to wrap the call in an anonymous function.

    $(document).on('dblclick', '#an_tnam tr', function(event) {
        ADS('hello');
    });
    

    jQuery always passes its normalized event object as the first argument to the function to be executed.

提交回复
热议问题