我无法将我的jquery链接到我的html。这是一个如此简单的步骤,但让我疯了。这是我的HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8"/>
<title> Hucke Buckle Project </title>
<link rel="stylesheet" type="text/css" href="huckle.css">
<script src= "huckle.js" type="text/javascript"></script>
<script src = "jquery-migrate-1.2.1.js"></script>
<script src ="jquery-2.1.0.js"></script>
</head>
<body>
<form>
<input type="number" class="num" name="number"><br>
</form>
<div id="buttons">
<button type="button" class="subm" > Submit </button>
<button type="reset" class="reset"> Reset </button>
</div>
</body>
</html>
我的HTML和jQuery文件在同一个文件夹中,我无法弄清楚它们为什么没有链接。
这是jQuery代码:
$(document).ready(function() {
var i=0;
var scopedVal;
var checkNum = Math.floor(Math.random() * 10);
alert(checkNum);
/*var hotCheck = function(scopedVal, submitVal) {
if (Math.abs(checkNum - scopedVal) >= Math.abs(checkNum - submitVal))
{
alert("hotter, try again!");
}
else { alert("colder, try again!");}
}
*/
$('.subm').on('click', function() {
i++;
/*var submitVal = $(this).closest('form').find('.num').val();
alert('submitval is' + submitVal);
if(checkNum === submitVal)
{ alert('Got IT!');}
else {if(i<=1){
alert('try again');
scopedVal = submitVal;
}
else {
hotCheck(scopedVal, submitVal);
scopedVal = submitVal;
}
}
*/
});
});
答案 0 :(得分:0)
您的脚本以错误的顺序加载。
你有
应该是