javascript - Moving the order of screen items with a mouse click -


on screen have simple list of items:

  1. item 1
  2. item 2
  3. item 3

i have seen examples of user can click on item , change position in list mouse.

mu question is, how done? javascript function of sorts?

you can use jquery ui library accomplish easily. follow snippet

  #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }    #sortable li { background:#aeaeae; margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }    #sortable li span { position: absolute; margin-left: -1.3em; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>         <script>    $(function() {      $( "#sortable" ).sortable();      $( "#sortable" ).disableselection();    });    </script>       <ul id="sortable">     <li>item 1</li>     <li>item 2</li>     <li>item 3</li>     <li>item 4</li>     <li>item 5</li>     <li>item 6</li>  </ul>


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -