Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

jQuery Mobile Toolbar theme Option

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like 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 use the jQuery Mobile Toolbar theme option. The Toolbar theme option is used to set the color scheme for the toolbar. It accepts a single letter (a-z) which maps to a swatch in the theme.

Syntax:

$(".selector").toolbar({
   theme: "b"
});

 

CDN Links: First, add jQuery Mobile scripts needed for your project.

<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css” />
<script src=”https://code.jquery.com/jquery-2.1.3.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js”></script>

Example 1: 

HTML




<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0" />
  
    <link rel="stylesheet" 
          href=
    <script src=
    </script>
    <script src=
    </script>
  
    <script>
      function changeTheme() {
        $("#divID").toolbar("option", "theme", "b");
      }
    </script>
  </head>
  <body>
    <div data-role="page">
      <center>
        <h2 style="color:green">GeeksforGeeks</h2>
        <h3>jQuery Mobile Toolbar theme option</h3>
  
        <div id="divID" data-role="header">
          <h1>Toolbar</h1>
        </div>
  
        <button style="width:250px; margin:30px 0" 
                onclick="changeTheme();">
          Change Theme to swatch b
        </button>
      </center>
    </div>
  </body>
</html>

Output:

Mobile Toolbar theme Option

Example 2: Now let’s create a new swatch that maps to the letter “c” and use the theme option to change the theme of the toolbar.

HTML




<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible"
          content="IE=edge" />
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" 
          href=
    <script src=
    </script>
    <script src=
    </script>
    <style>
      /* Custom swatch "c" just for toolbar */
      .ui-bar-c{
          background-color: #009245; /* toolbar background color*/
          border-color: #dddddd; /* toolbar border color*/
          color: #ffffff; /* toolbar text color*/    
        }      
    </style>
  
    <script>
        function changeTheme() {
          $("#divID").toolbar("option", "theme", "c");
        }
    </script>    
  </head>
  <body>
    <div data-role="page">
      <center>
        <h2 style="color:green">GeeksforGeeks</h2>
        <h3>jQuery Mobile Toolbar theme option</h3>
  
        <div id="divID" data-role="header">
          <h1>Toolbar</h1>
        </div>
  
        <button style="width:250px; margin:30px 0"
                onclick="changeTheme();">
             Change Theme to swatch c
        </button>
      </center>
    </div>
  </body>
</html>

Output:

Mobile Toolbar theme Option

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


My Personal Notes arrow_drop_up
Last Updated : 28 Dec, 2021
Like Article
Save Article
Similar Reads
Related Tutorials