Why is using onClick() in HTML a bad practice?

前端 未结 10 2151
我寻月下人不归
我寻月下人不归 2020-11-21 05:07

I have heard many times that using JavaScript events, such as onClick(), in HTML is a bad practice, because it\'s not good for semantics. I would like to know w

10条回答
  •  抹茶落季
    2020-11-21 05:36

    • onclick events run in the global scope and may cause unexpected error.
    • Adding onclick events to many DOM elements will slow down the
      performance and efficiency.

提交回复
热议问题