jQuery.click() vs onClick

前端 未结 17 1503
情话喂你
情话喂你 2020-11-21 07:35

I have a huge jQuery application, and I\'m using the below two methods for click events.

First method

HTML

17条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-21 08:14

    $('#myDiv').click is better, because it separates JavaScript code from HTML. One must try to keep the page behaviour and structure different. This helps a lot.

提交回复
热议问题