Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

JavaScript Comments

Comments in JavaScript (and in other scripting languages, including ActionScript and other ECMA Script derivatives) are preceded by //. As in the previous example, being able to locate all comments in a page at once can be very useful.

<SCRIPT LANGUAGE="JavaScript">
// Turn off fields used only by replace
function hideReplaceFields() { 
 document.getElementById(‘RegExReplace’).disabled=true;
 document.getElementById(‘replaceheader’).disabled=true;
} 
// Turn on fields used only by replace
function showReplaceFields() { 
 document.getElementById(‘RegExReplace’).disabled=false;
 document.getElementById(‘replaceheader’).disabled=false;
} 
//.*
<SCRIPT LANGUAGE="JavaScript">
// Turn off fields used only by replace
function hideReplaceFields() { 
 document.getElementById(‘RegExReplace’).disabled=true;
 document.getElementById(‘replaceheader’).disabled=true;
} 
// Turn on fields used only by replace
function showReplaceFields() { 
 document.getElementById(‘RegExReplace’).disabled=false;
 document.getElementById(‘replaceheader’).disabled=false;
} 

This is a simple one; //.* matches // followed by the comment body.

  • + Share This
  • 🔖 Save To Your Account