Open In App

jQuery Mobile Controlgroup direction Option

Last Updated : 30 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

jQuery Mobile is a web-based technology and great building UI interfaces for the webpages that can be used to make responsive content for websites that can be accessed on all types of smartphones, tablets, and desktops.  

In this article, we will be using the jQuery Mobile Controlgroup direction option to add the direction of controlgroup elements. Its default value is vertical.

Syntax: 

The below syntax is used to initialize the controlgroup with the direction option.

$( ".selector" ).controlgroup({
  direction: "horizontal"
});
  • Get the direction option.

    var direction = $( ".selector" ).controlgroup( "option", "direction" );
  • Set the direction option.

    $( ".selector" ).controlgroup( "option", "direction", "horizontal" );

CDN Links: Add the following jQuery Mobile scripts that you will need in your project.

<link rel=”stylesheet” href=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css”>
<script src=”//code.jquery.com/jquery-3.2.1.min.js”></script>
<script src=”//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js”></script>

Example: This example demonstrates the jQuery Mobile Controlgroup direction option.

HTML




<!doctype html>
<html lang="en">
  
<head>
    <meta charset="utf-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1">
  
    <link rel="stylesheet" 
          href=
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.css">
      
    <script src=
"//code.jquery.com/jquery-3.2.1.min.js">
   </script>    
    <script src=
"//code.jquery.com/mobile/1.5.0-alpha.1/jquery.mobile-1.5.0-alpha.1.min.js">
   </script>
  
    <script>
        $(function () {
            $("#btn").on('click', function () {
                $("#divID").controlgroup({
                    type: "horizontal"
                });
            });
        });
    </script>
</head>
  
<body>
    <center>
      <div data-role="page" id="page1">
        <div data-role="header">
            <h1 style="color:green;">GeeksforGeeks</h1>
            <h3> jQuery Mobile Controlgroup direction Option</h3>
        </div>
  
        <div role="main" class="ui-content">
            <div data-role="controlgroup" id="divID">
                <a href=
                    class="ui-btn">
                    Data Structure
                </a>
                <a href=
                    class="ui-btn">
                    Algorithm
                </a>
                <a href=
                    class="ui-btn">
                    Web Development
                </a>
                <a href=
                    class="ui-btn">
                    Java Programming
                </a>
            </div>
        </div>        
         <input type="button" id="btn"
                style="width:250px;" 
                value="Change to Horizontal">
  
       </div>
    </center>
</body>
</html>


Output:

jQuery Mobile Controlgroup direction Option

jQuery Mobile Controlgroup direction Option

Reference: https://api.jquerymobile.com/controlgroup/#option-direction



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads