jquery on click event that call a named function

后端 未结 6 622
青春惊慌失措
青春惊慌失措 2020-12-30 12:10

I have a jQuery onClick handler, writed with an anonymous function like that:

$(\"#selector\").on(\"click\" function(){
    // do something
})
<         


        
6条回答
  •  抹茶落季
    2020-12-30 12:40

    Just pass the reference of that function itself.

    Try,

    $("#selector").on("click", namedFunction);
    

提交回复
热议问题