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

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

I have the following script which does not work



        
6条回答
  •  耶瑟儿~
    2021-01-31 08:56

    function ADS(e) {
        return function() {
            alert(e);
        };
    }
    

    Like that when you're doing

    $(document).on("dblclick","#an_tnam tr", ADS('hello'));
    

    , it is the returned function that is assigned as event handler (and your string argument is passed when you're assigning the handler, not when it's called).

提交回复
热议问题