简体   繁体   中英

.draggable is not working on a div

I have worked with .draggable() function before and it worked fine the previous time. However this time it is not even working. I have no idea why?

These are my jQuery links

<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<link rel="stylesheet" href="https//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">

This is my HTML Code

<div class="mainArea" id="response"> 
    <div class="designer">
        <?php include"shirtBasic.svg" ?>
        <div id="imageDiv"> </div>
        <div id="dragDiv"> </div>
    </div>
    <table width="100%" border="0" id="sizeBar">
        <tr>
            <td class="leftBarButton" style="width:50%">Front</td>
            <td class="leftBarButton" style="width:50%">Back</td> 
        </tr>
    </table>
</div>

and this is the jQuery

$(document).ready(function() {
    $(function() {
        $('#dragDiv').draggable();
    });
});

This is not the only code there is other code above and below HTML and jQuery as well but not relevant.

Please help me find the problem and suggest if I have linked the correct versions of jQuery, if there is a newer available please enlighten me.

Your code works well... http://jsfiddle.net/m6ac80wb/2/

You should use only one version of JQUERY. You can keep the latest one https://code.jquery.com/jquery-2.1.1.js

Also, don't forget to import the jquery-2.1.1.js before the jquery-ui.js .

You can try using:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">

It works if you try it that way, and also your stylesheet was missing the ":" in the url, it is not the reason it wasn't working, but I thought I should point it out.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM