Home  >  Article  >  Web Front-end  >  Js basic learning materials_basic knowledge

Js basic learning materials_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:15:40973browse

1. To prevent problems with browsers that do not support js, you can handle the JS code like this


2. JS placement location:
header: Make sure the script is loaded when it is called
body: the page is loaded When entering, call the <script> external js file: does not contain the <BR> tag <script src = "xxx.js"> usage: ...<BR> <BR> 3. Comment <BR> single line: // <BR> more Line: /*.....*/ <BR>4. The congruent symbol indicates that the types and values ​​are equal <BR>5. Three prompt boxes <BR>Warning: alert("alert"); <BR>Confirm: confirm("confirm"); <BR>Prompt: prompt("prompt","default value"); <BR>6. for in statement<BR>for (variable in object) <BR>{ <BR>Execute code here<BR>} <BR>7. Regular expression<BR>test() method: Retrieve the specified value in the string, return True if there is one, otherwise False <BR>var patt1=new RegExp( "e"); <BR>document.write(patt1.test("The best things in life are free")); <BR>exec() method: retrieve the specified value in the character, and return the found value if there is one , otherwise return null <BR>var patt1=new RegExp("e"); <BR>document.write(patt1.exec("The best things in life are free")); <script type="text/javascript"> <BR><!-- <BR>document.write("Hello World!"); <BR>//--> <BR></script>compile() method: use For changing the search mode and adding or removing the second parameter

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn