Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptscript.aculo.us Sorting tag Option

script.aculo.us Sorting tag Option

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:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments