您好,在过去的 3 个小时里,我一直遇到此代码的问题,我希望有人能够在这里帮助我。
jQuery
$(document).ready(function() {
$("img").draggable();});
HTML 标头
<head>
<title>Chess</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" type="text/css" href="reset.css" />
<link rel="stylesheet" type="text/css" href="default.css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="default.js"></script>
</head>
萤火虫错误
TypeError: $("img").draggable is not a function [Break On This Error] $("img").draggable();
我的代码在codecademy.com上运行良好,但是当我在 localhost 或我的服务器上尝试时,我不断收到此错误消息。我在这里做错了什么?
完整的 HTML
<!DOCTYPE html>
<html>
<head>
<title>Chess</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" type="text/css" href="reset.css" />
<link rel="stylesheet" type="text/css" href="default.css"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="default.js"></script>
</head>
<body>
<div id="board">
<ul id="first_row">
<li class="white_space"><img src="pieces/Rook_Black.png" /></li>
<li class="black_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="pieces/Pawn_White.png" /></li>
<li class="black_space"><img src="pieces/Rook_White.png" /></li>
</ul>
<ul id="second_row">
<li class="black_space"><img src="pieces/Knight_Black.png" /></li>
<li class="white_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="pieces/Pawn_White.png" /></li>
<li class="white_space"><img src="pieces/Knight_White.png" /></li>
</ul>
<ul id="third_row">
<li class="white_space"><img src="pieces/Bishop_Black.png" /></li>
<li class="black_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="pieces/Pawn_White.png" /></li>
<li class="black_space"><img src="pieces/Bishop_White.png" /></li>
</ul>
<ul id="forth_row">
<li class="black_space"><img src="pieces/Queen_Black.png" /></li>
<li class="white_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="pieces/Pawn_White.png" /></li>
<li class="white_space"><img src="pieces/King_White.png" /></li>
</ul>
<ul id="fifth_row">
<li class="white_space"><img src="pieces/King_Black.png" /></li>
<li class="black_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="pieces/Pawn_White.png" /></li>
<li class="black_space"><img src="pieces/Queen_White.png" /></li>
</ul>
<ul id="sixth_row">
<li class="black_space"><img src="pieces/Bishop_Black.png" /></li>
<li class="white_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="pieces/Pawn_White.png" /></li>
<li class="white_space"><img src="pieces/Bishop_White.png" /></li>
</ul>
<ul id="seventh_row">
<li class="white_space"><img src="pieces/Knight_Black.png" /></li>
<li class="black_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="pieces/Pawn_White.png" /></li>
<li class="black_space"><img src="pieces/Knight_White.png" /></li>
</ul>
<ul id="eight_row">
<li class="black_space"><img src="pieces/Rook_Black.png" /></li>
<li class="white_space"><img src="pieces/Pawn_Black.png" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="#" /></li>
<li class="white_space"><img src="#" /></li>
<li class="black_space"><img src="pieces/Pawn_White.png" /></li>
<li class="white_space"><img src="pieces/Rook_White.png" /></li>
</ul>
</div>
</body>
</html>