开发者

Should I put a Semicolon (;) when I use onclick=""

开发者 https://www.devze.com 2023-02-10 07:16 出处:网络
Should I put a Semicolon (;) when I use onclick=\"\"? <p onclick=\"clo开发者_Go百科seLightBox();\">Click<p>

Should I put a Semicolon (;) when I use onclick=""?

<p onclick="clo开发者_Go百科seLightBox();">Click<p>

or:

<p onclick="closeLightBox()">Click<p>


The semicolon in this position, is valid, but not mandatory.


It is good practice to include it, since if you decide to add other statements after the call, it is clear and easy to do so. However, the code will run either way.


I prefer a semicolon. I know it is optional (as it is many times in JS), but I like to be uniform and it helps to alert the person that the statement is complete.


As an optional semicolon, it's a matter of taste.

0

精彩评论

暂无评论...
验证码 换一张
取 消