Should I put a Semicolon (;) when I use onclick=""
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.
精彩评论