JavaScript code", the syntax for introducing ".js" files is ""."/> JavaScript code", the syntax for introducing ".js" files is "".">
Home > Article > Web Front-end > Is JavaScript code embedded in HTML?
JavaScript code is embedded in html. You can also write JavaScript code in a ".js" file and use the script tag to introduce the ".js" file into html; JavaScript code is embedded in html. The syntax is "3f1c4e4b6b16bbbd69b2ee476dc4f83aJavaScript code2cacc6d41bbb37262a98f745aa00fbf0", and the syntax for introducing ".js" files is "8da1ad472526c011583b5dddba848f452cacc6d41bbb37262a98f745aa00fbf0".
The operating environment of this tutorial: windows10 system, javascript1.8.5&&html5 version, Dell G3 computer.
Is JavaScript embedded in HTML?
Use script tag to insert script code
<!doctype html> <html> <head> <meta charset="utf-8"> <title>在HTML标签的事件属性中直接添加脚本</title> <script> function 单击(){ alert("hello world"); } </script> </head> <body> <form> <input type="button" onClick="单击()" value="单击"/> </form> </body> </html>
Use script tag to link external JS files
JS code/** * */ function 单击(){ alert("hello world") }HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>使用script标签链接外部JS文件</title> <script type="text/javascript" src="test.js"></script> </head> <body> <input type="button" onclick="单击()" value="单击"> </body> </html>[Related recommendations:
javascript video tutorial, web front-end】
The above is the detailed content of Is JavaScript code embedded in HTML?. For more information, please follow other related articles on the PHP Chinese website!