xrcwrn
xrcwrn

Reputation: 5325

How to drag and position a div

I have three div in a page I want user can reposision div as the want

<div class="A"></div>
<div class="B"></div>
<div class="C"></div>

Originally it is ordered ABC. User can reposition div as CBA, CAB as user want How to do this.

Upvotes: 0

Views: 65

Answers (1)

J Prakash
J Prakash

Reputation: 1333

HTML :

<div class="sortable">
     <div class="A"></div>
     <div class="B"></div>
     <div class="C"></div>
</div>

Jquery :

 <script>
     $(function() {
       $( "#sortable" ).sortable();
       $( "#sortable" ).disableSelection();
     });
</script>

Add these jquery files to your code :

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

Upvotes: 3

Related Questions