Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YES or NO to semicolon in object events

I've searched, but didn't find answer to this question. Should HTML DOM EVENTS, like onChange, onSelect, onKeyUp, onFocus, onClick etc. contain semicolon, example two lines below.

onChange="this.form.submit();" OR onChange="this.form.submit()"

"YES" or "NO" or "Doesn't Matter"

I guess it doesn't matter, but again, what's the best, most right to do?

THANKS ALL!

like image 549
ProDraz Avatar asked Aug 23 '12 23:08

ProDraz


2 Answers

It doesn't matter.

The event handler attribute value is treated as a series of statements which are wrapped in a function signature similar to

 function (event) {
   with (event.target.ownerDocument) {
     with (event.target) {
       // attribute body goes here
     }
   }
 }

so you can put any group of SourceElements in the attribute value, and can leave off semicolons as per JavaScript's usual semicolon insertion rules.

like image 100
Mike Samuel Avatar answered Sep 18 '22 05:09

Mike Samuel


Never used it with semicolon, so I guess it doesn't matter.

like image 37
Zhafur Avatar answered Sep 18 '22 05:09

Zhafur