Open In App

jQWidgets jqxSortable containment Property

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful and optimized framework, platform-independent, and widely supported. jqxSortable represents a jQuery plugin which allows you to reorder elements in a html list or div tags using the mouse.

The containment property is used to define a bounding box that the sortable items are constrained while dragging. It accepts boolean/string type values and its default value is false.

Syntax:

  • Set the containment property:

    $('Selector').jqxSortable({ containment : boolean/string });
  •  

  • Return the containment property:

    var containment = $('Selector').jqxSortable('containment');

Linked Files: Download jQWidgets from the given link. In the HTML file, locate the script files in the downloaded folder:

<link type=”text/css” rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/globalization/globalize.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxsortable.js”></script>

Example: The below example illustrates the jqxSortable containment property in jQWidgets:

HTML




<!DOCTYPE html>
<html lang="en">
    
<head>
    <link type="text/css" rel="stylesheet" 
          href="jqwidgets/styles/jqx.base.css" />
    <script type="text/javascript" 
            src="scripts/jquery-1.11.1.min.js">
      </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxcore.js">
      </script>
    <script type="text/javascript" 
            src="jqwidgets/globalization/globalize.js">
      </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxsortable.js">
      </script>
</head>
    
<body>
    <h1 style="color: green">
          GeeksforGeeks 
    </h1>
    <h3>jQWidgets jqxSortable containment property</h3>
    <div id="sort1">
        <div class='gfg'><li>C</li></div>
        <div><li>C++</li></div>
        <div><li>Python</li></div>
        <div><li>HTML</li></div>
        <div><li>CSS</li></div>
        <div><li>JavaScript</li></div>
    </div>    
    
    <script type="text/javascript">
        $(document).ready(function () {
            $("#sort1").jqxSortable({
               containment: true
            });
        });
    </script>
</body>
  
</html>


Output:

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxsortable/jquery-sortable-api.htm



Last Updated : 14 Nov, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads