<!doctype html>
<html>
<head>
<meta charset="utf8">
<title>正确写jQuery</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h3>碧蓝空间
</header>
<nav>
<ul>
<li id="TitleInfo">实用链接:</li>
<li><a href="">新浪</a></li>
<li><a href="">百度</a></li>
<li><a href="">军事</a></li>
</ul>
</nav>
<p>记录你的生活:<textarea cols=50 rows=3 ></textarea>
<p><input type='submit' value='存档'></p>
<script type="text/javascript" src="jquery.js">
alert("您将要提交到服务器");
console.log("hello");
$('input[type="submit"]').on("click", function(){
alert("您将要提交到服务器");
})
</script>
</body>
</html>
上面代码中的<Script>标签之间JS代码不会执行,因为这个标签已经指明了是引用jQuery文件。应该在新的
<Script>标签中写代码:
<script type="text/javascript" src="jquery.js"> <script>
<script>
alert("您将要提交到服务器");
console.log("hello");
$('input[type="submit"]').on("click", function(){
alert("您将要提交到服务器");
})
</script>