Why in Javascript event handler functions with parentheses?

后端 未结 4 2415
轻奢々
轻奢々 2020-12-09 12:25

Javascript gurus, look at this code:


        

        
4条回答
  •  清歌不尽
    2020-12-09 13:11

    Anything you put inside onclick="" will be wrapped with an implicit function. That is the actual event handler that will be called on click, any function call inside it needs the parentheses.

提交回复
热议问题