Introduction to JavaScript
JavaScript Introduction
JavaScript is the programming language of the Web. All modern HTML pages use JavaScript.
JavaScript is the most popular scripting language on the Internet. This language can be used for HTML and web, and can be widely used on servers, PCs, laptops, tablets, smartphones and other devices .
JavaScript is a scripting language
JavaScript is a lightweight programming language .
JavaScript is programming code that can be inserted into HTML pages.
JavaScript, when inserted into an HTML page, can be executed by all modern browsers.
JavaScript is easy to learn.
Example
Let’s look at a program that turns lights on and off through JavaScript
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <script> function changeImage() { element=document.getElementById('myimage') if (element.src.match("580d64d73ed01442")) { element.src="/upload/course/000/000/006/580d64a8c09d6449.gif"; } else { element.src="/upload/course/000/000/006/580d64d73ed01442.gif"; } } </script> <img id="myimage" onclick="changeImage()" src="/upload/course/000/000/006/580d64a8c09d6449.gif" width="100" height="180"> <p>點擊燈泡就可以打開或關(guān)閉這盞燈</p> </body> </html>
Run the program and try it