JavaScript
The Internet's most popular scripting language that can be used for HTML and web, server, PC, tablet, mobile devices, etc.
A lightweight programming language
Can insert HTML programming code, can be performed by all modern browsers after inserting HTML
Example: JavaScript writing HTML input stream
. If you use it after the document has loaded (for example, in a function), will cover the entire document. </ P > < Script type = "text / JavaScript" charset = "UTF-. 8" > document.write ( " <h1 of> the JS output stream number written HTML1 title </ h1 of> " ) document.write ( " <H3> the JS The title number is written to the output stream HTML3 </ H3> " ) </ Script > </ body > </ HTML >
JS response to the event:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>W3Cschool教程(w3cschool.cn)</title> </head> <body> <button type="button" onclick="alert('点我试试')">111</button> </body> </html>
JS to change the content of a paragraph:
<! DOCTYPE HTML > < HTML > < head > < Meta charset = "UTF-. 8" > < title > W3Schools tutorial (w3cschool.cn) </ title > </ head > < body > < P ID = "Change" > this is an eagerly to be slaughtered paragraphs! </ P > < Button type = "Button" the onclick = "functionCg ()" > Variable! </ Button > ="text/javascript" charset="utf-8"> function functionCg(){ x = document.getElementById("change"); x.innerHTML = "haha"; } </script> </body> </html>
Light control switch JS:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>W3Cschool教程(w3cschool.cn)</title> </head> <body> <script type="text/javascript" charset="utf-8"> // element.src="/statics/images/course/pic_bulboff.gif"; // element.src="/statics/images/course/pic_bulbon.gif"; // src="/statics/images/course/pic_bulboff.gif" function cglt(){ x = document.getElementById("light"); if(x.src.match("/statics/images/course/pic_bulboff.gif")){ x.src = "/statics/images/course/pic_bulbon.gif"; }else{ x.src = "/statics/images/course/pic_bulboff.gif"; } } </script> <img id="light" src="/statics/images/course/pic_bulboff.gif" alt="这就尴尬了!" onclick="cglt()" width="100px" height="100px"/> </body> </html>