Skip to content
Related Articles

Related Articles

script.aculo.us Sorting tag Option
  • Last Updated : 03 Dec, 2020

The tag option in the Sortable module is used to specify the type of elements that have to be made sortable in the container. Its default value is ‘li’, which is the list element.

Syntax:

 Sortable.create( container_id, {tag: container_type} );

Example 1:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript" 
        src="scriptaculous.js">
    </script>
  
    <script>
        window.onload = function () {
            Sortable.create(
                'list', { tag: 'li' }
            );
        }
    </script>
      
    <style>
        li {
            cursor: move;
        }
    </style>
</head>
  
<body>
    <ul id="list">
        <li>tag</li>
        <li>overlap</li>
        <li>constraint</li>
        <li>containment</li>
        <li>handle</li>
    </ul>
</body>
  
</html>

chevron_right


Output:



Example 2: In this example, images in a container have been made sortable with the div tag.

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript"
        src="scriptaculous.js">
    </script>
  
    <script>
        window.onload = function () {
            Sortable.create(
                'imageContainer',
                { tag: 'div' }
            );
        }
    </script>
      
    <style>
        div {
            cursor: move;
        }
    </style>
</head>
  
<body>
    <div id="imageContainer">
        <div><img src="gfg.png" /></div>
        <div><img src="gfg1.png" /></div>
    </div>
</body>
  
</html>

chevron_right


Output:

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :