JavaScript(行内,内嵌,外部)
作者:互联网
JS三种书写位置
-
行内式的js 直接写到元素的内部
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <input type="button" value="唐伯虎" onclick="alert('秋香姐')" /> </body> </html>
-
内嵌式的js
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> </body> <script type="text/javascript"> alert('唐伯虎点秋香'); </script> </html>
-
外部js
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="js/01.js" type="text/javascript" charset="utf-8"></script> </head> <body> </body> </html>
js文件:
alert('向往的生活');
标签:内嵌,行内,内嵌式,外部,JavaScript,alert,js 来源: https://www.cnblogs.com/gyy2304/p/14805631.html