HTML scriptLOGIN

HTML script

HTML script generally refers to some scripting languages, such as JavaScript, VBScript, etc.
The way to embed a script in HTML is:
<script type="text/javascript">
//JavaScript code
</script>
Scripts are mainly used to operate HTML documents and implement related functions or special effects.

a <script> tag
If you want to insert a JavaScript script into an HTML page, please use the <script> tag. <script> and </script> tell JavaScript where to start
and end. The lines between

<script> and </script> contain JavaScript:

##<span style="font-size: 18px;"><script type="text/javascript">

alert("Welcome to the world of JavaScript!!!");

</script></span>

<noscript> Tag## The

#<noscript> tag provides alternative content when scripting is not available, such as when scripting is disabled in the browser, or when the browser does not support client-side scripting. . The <noscript> element can contain all elements found within the body element of a normal HTML page.

Only when the browser does not support scripts or scripts are disabled, the content in the <noscript> element will be displayed:

<noscript>Sorry, your The browser does not support JavaScript!</noscript>


# JavaScript experience (from the javascript tutorial on this site)

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>JavaScript脚本语言</title> 
<script type="text/javascript"> 
function myFunction() 
{ 
document.getElementById("demo").innerHTML="My First JavaScript Function"; 
} 
</script> 
</head> 
  
<body> 
<h1>My Web Page</h1>  
  
<p id="demo">A Paragraph.</p>  
  
<button type="button" onclick="myFunction()">点击这里</button> 
</body>
</html>
Tips:

You don’t need to understand the above code, just understand it.

Get the current time instance:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>JavaScript脚本语言</title> 
   <script type="text/javascript">
        window.onload = function () {
            setTime();
        }
        function setTime() {
            var div = document.getElementById("d1");
            var time = new Date();
            //如果获取月份(月份从0开始 + 1)
            div.innerHTML = set(time.getHours()) + ":" + set(time.getMinutes()) + ":" + set(time.getSeconds());
        }
        //
        function set(num) {
            if (num < 10) {
                return "0" + num;
            } else {
             return num;
            }
        }
        setInterval("setTime()",1000);
    </script>
</head>
<body>
    <div id="d1"></div>
</body>
</html>

Try it

Next Section

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JavaScript脚本语言</title> <script type="text/javascript"> function myFunction() { document.getElementById("demo").innerHTML="My First JavaScript Function"; } </script> </head> <body> <h1>My Web Page</h1> <p id="demo">A Paragraph.</p> <button type="button" onclick="myFunction()">点击这里</button> </body> </html>
submitReset Code
ChapterCourseware