Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

 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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!