Open In App

script.aculo.us Sorting tag Option

Last Updated : 03 Dec, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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




<!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>


Output:

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

HTML




<!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>


Output:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads