Skip to content
Related Articles
Open in App
Not now

Related Articles

jQuery Mobile Loader theme Option

Improve Article
Save Article
  • Last Updated : 07 Feb, 2022
Improve Article
Save Article

jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops.

In this article, we will learn to use the jQuery Mobile Loader theme Option. Using this option, we can set the color scheme (swatch) for the loader widget. It accepts a single letter from a-z that maps to the swatches included in the theme. The default value of this option is ‘null or the value inherit from the parent‘.

Syntax:

The Syntax to initialize the loader with the theme option is specified below:

$( ".selector" ).loader({
    theme: "b"
});
or
$.mobile.loading( 'show', {
   theme : "b"
});
  • Get the theme option:

    var theme = $( ".selector" ).loader( "option", "theme" );
    or
    var theme = $.mobile.loader.prototype.options.theme;
  • Set the theme option:

    $( ".selector" ).loader( "option", "theme", "b");
    or
    $.mobile.loader.prototype.options.theme= "b";

CDN Links: Add the below jQuery Mobile scripts that will be needed for 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 Loader theme 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>
      
</head>
  
<body>
    <center>
        <div data-role="page" id="page1">
            <div data-role="header">
                <h1 style="color:green;">GeeksforGeeks</h1>
                <h3>
                    jQuery Mobile Loader theme Option
                </h3>
            </div>
            <div role="main" class="ui-content">
                <div data-role="controlgroup">
                    <button class="show" >Default Theme</button>
                    <button class="show" data-theme="b">
                        Dark Theme
                    </button>
                    <button class="hide" >Hide</button>
                </div>
            </div>
        </div>
    </center>
      
    <script>
        $(document).on( "click", ".show", function() {
          var $this = $( this );
        $.mobile.loading( 'show', {
            theme: $this.jqmData( "theme" ) || 
                   $.mobile.loader.prototype.options.theme
          });
        })
        .on( "click", ".hide", function() {
          $.mobile.loading( "hide" );
        });
    </script>
</body>
</html>


Output:

jQuery Mobile Loader theme Option

jQuery Mobile Loader theme Option

Reference: https://api.jquerymobile.com/loader/#option-theme


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!