Open In App

jQuery Mobile Loader text Option

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 be using the jQuery Mobile Loader text Option to set the text of the message. The default value of this option is ‘Loading‘.



Syntax:

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



$( ".selector" ).loader({
 text: "Loading Page..."
});
or
$.mobile.loading( "show", {
 text: "Loading Page..."
});

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 text Option.




<!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 html Option
                </h3>
            </div>
            <div role="main" class="ui-content">
                <div data-role="controlgroup">
                  <button class="show" data-theme="b" 
                        data-textvisible="true" 
                        data-msgtext="Loading Page ...">
                    Text</button>
                </div>
            </div>
        </div>
    </center>
      
    <script>
        $(document).on( "click", ".show", function() {
          var $this = $( this );
        $.mobile.loading( 'show', {
            textVisible: $this.jqmData( "textvisible" ) || 
            $.mobile.loader.prototype.options.textVisible,
            text: $this.jqmData( "msgtext" ) || 
                  $.mobile.loader.prototype.options.text
          });
        })
        ;
    </script>
</body>
</html>

Output:

jQuery Mobile Loader text Option

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


Article Tags :