JQuery UI draggable doesn't work at all!

Why doesn't this work for me at all?

<script type="text/javascript" src="Javascript/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="Javascript/jquery-1.3.2.min.js"></script>     
<script type="text/javascript">

    $(function() {
    $('.selector').draggable({ axis: 'x' });    });

    </script>

    <body>

    <div class="selector">
        <p>Drag me around</p>
    </div>

I literally just copied and pasted from the drag and drop example page to the jQuery site, and it just doesn't work :(

Can someone tell me why?

+3
source share
2 answers

Change the order of javascript inclusion, there will always be the first jQuery core file.

+15
source

It may seem trivial, but you need to load the jQuery library before the jQuery UI:

<script type="text/javascript" src="Javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="Javascript/jquery-ui-1.7.2.custom.min.js"></script>     
<script type="text/javascript">
  $(function() {
    $('.selector').draggable({ axis: 'x' });
  });
</script>
<body>
  <div class="selector">
    <p>Drag me around</p>
  </div>
+5
source

Source: https://habr.com/ru/post/1724647/


All Articles