我想要我的HTML文檔輸出龍與地下城的隨機數。但是,代碼無法正常工作,我無法解決原因。jQuery/JavaScript腳本標記不工作
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.10.2.js">
$(document).ready(function(){
$("#d4").click(function(){
var out = Math.random(1,4);
alert(out);
};
});
</script>
</head>
<body>
<p id ="d4">Roll a d4</p>
</body>
</html>
它是如何工作的? – Yatrix
將您的document.ready代碼放在jquery腳本標記後的單獨腳本標記中。 – WebServer