On the W3 tutorial, it shows htis code:
In browsers that do understand JavaScript the opening <--
html comment is ignored and the JS code is executed. The JS comment //
on the last line then prevents the closing -->
being taken as an error by the JS engine. In browsers that don't understand JavaScript everything between <--
and -->
is taken as an html comment and ignored.
This whole thing was a precaution for older browsers that didn't know about JS. It is not necessary for any modern browser.
If you want to comment out a block of JS enclose the block in /*
and */
.