It is really weird that the draggable works in all browsers but Firefox. I tried in IE6.0, Opera, Safari, all are ok. But Firefox prompted below error:
$("#draggable").draggable
is not a function.
Here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="/js/ui/1.8.5/themes/base/jquery.ui.all.css"/>
<script type="text/javascript" src="/js/ui/1.8/js/jquery-1.4.2.min.js"></script>
<script type="text/jscript" src="/js/ui/1.8/ui/jquery.ui.core.js"></script>
<script type="text/jscript" src="/js/ui/1.8/ui/jquery.ui.widget.js"></script>
<script type="text/jscript" src="/js/ui/1.8/ui/jquery.ui.mouse.js"></script>
<script type="text/jscript" src="/js/ui/1.8/ui/jquery.ui.draggable.js"></script>
<style type="text/css">
#draggable { width: 150px; height: 150px; padding: 0.5em;}
</style>
<script type="text/javascript">
$(function() {
$( "#draggable" ).draggable();
});
</script>
</head>
<body>
<div class="demo">
<div id="draggable" class="ui-widget-content">
<p>Drag me around</p>
</div>
</div>
</body>
</html>
The content types should be text/javascript
, you currently have text/jscript
for the jQuery UI files, like this:
<script type="text/javascript" src="/js/ui/1.8/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="/js/ui/1.8/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/js/ui/1.8/ui/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="/js/ui/1.8/ui/jquery.ui.draggable.js"></script>
Or include the entire jQuery UI library from the a CDN in one file, for example:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
jscript
is specifically for IE, but other browsers may or may not tolerate it and treat it as a JavaScript content type, for it to work everywhere stick with text/javascript
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.