How does inline Javascript (in HTML) work?

前端 未结 6 722
醉酒成梦
醉酒成梦 2020-11-28 19:21

I know this is bad practice. Don\'t write code like this if at all possible.

Of course, we\'ll always find ourselves in situations where a clever snippet of inline

6条回答
  •  孤独总比滥情好
    2020-11-28 19:46

    There seems to be a lot of bad practice being thrown around Event Handler Attributes. Bad practice is not knowing and using available features where it is most appropriate. The Event Attributes are fully W3C Documented standards and there is nothing bad practice about them. It's no different than placing inline styles, which is also W3C Documented and can be useful in times. Whether you place it wrapped in script tags or not, it's gonna be interpreted the same way.

    https://www.w3.org/TR/html5/webappapis.html#event-handler-idl-attributes

提交回复
热议问题