Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6139637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:00:58+00:00 2026-05-23T18:00:58+00:00

I have the following html code <!DOCTYPE html> <html lang=en> <head> <meta name=viewport content=width=device-width;

  • 0

I have the following html code

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width; initial-scale=1.0" />
        <link rel="stylesheet"  href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" />
        <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>
    </head>
    <body>
        <div data-role="page" id="home">
            <div data-role="header" data-theme="b">
                <h1>Test</h1>
            </div>
            <div data-role="content" data-theme="d">
                <div data-role="navbar" data-theme="d">
                    <ul>
                        <li><a href="#" data-icon="custom" class="ui-btn-active">Home</a></li>
                        <li><a href="#" data-icon="grid">Second page</a></li>
                        <li><a href="#" data-icon="star">Third page</a></li>
                    </ul>
                </div>
            </div>

        </div>

    </body>
</html>

What I want to achieve is to set some styles for the currently active tab in the navbar and change the icon and background for the selected tab(icon will be different for different tabs).

Using this CSS I can target the active tab

.ui-btn-active{
    background:red !important;
}

But I want to target each tabs separately because I need separate selected icons for each tab(Or lets say,for ease of illustration purpose-I need a different active tab color for each tab:red for first,blue for second,green for third)

You can see it here – http://jsfiddle.net/8pwFK/

Please let me know how to achieve this.Thanks in advance

Edit:The real challenge I am facing is setting a selected state for my custom icon.This is the CSS I use for the custom icon:

.tab1 .ui-icon { background:  url(icon1.png) 50% 50% no-repeat; background-size: 30px 30px; }

I think I need to somehow connect .ui-btn-active and .ui-icon for this to work.But I am not able to figure out how.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:00:58+00:00Added an answer on May 23, 2026 at 6:00 pm

    Add a id to each element you want to style like so with css:

    Live Example:

    • http://jsfiddle.net/phillpafford/8pwFK/4/

    HTML:

    <li><a href="#" data-icon="custom" class="ui-btn-active" id="custom-li-1">Home</a></li>
    <li><a href="#" data-icon="grid" id="custom-li-2">Second page</a></li>
    <li><a href="#" data-icon="star" id="custom-li-3">Third page</a></li>
    

    CSS:

    #custom-li-1.ui-btn-active {
        background:green !important;
    }
    
    #custom-li-2.ui-btn-active {
        background:red !important;
    }
    
    #custom-li-3.ui-btn-active {
        background:blue !important;
    }
    

    Docs for Custom Icons:

    • http://jquerymobile.com/demos/1.0b1/docs/buttons/buttons-icons.html
    • http://jquerymobile.com/demos/1.0b1/docs/toolbars/docs-navbar.html

    Custom Icons

    To use custom icons, specify a data-icon value that has a unique name like myapp-email and the button plugin will generate a class by prefixing ui-icon- to the data-icon value and apply it to the button. You can then write a CSS rule that targets the ui-icon-myapp-email class to specify the icon background source. To maintain visual consistency, create a white icon 18×18 pixels saved as a PNG-8 with alpha transparency.

    and

    Using 3rd party icon sets

    You can add any of the popular icon libraries like Glyphish to achieve the iOS style tab tab that has large icons stacked on top of text labels. All that is required is a bit of custom styles to link to the icons and position them in the navbar. Here is an example using Glyphish icons and custom styles (view page source for styles) in our navbar:

    Related Links:

    • A bottom navbar in jQuery mobile looking like iPhone navbar, possible?
    • http://jsfiddle.net/vh4Ca/62/

    UPDATE:

    Here is the what I think you’re looking for:

    • http://jsfiddle.net/phillpafford/8pwFK/29/

    JS:

    $('#custom-li-1').click(function() {
        $(this).attr('data-icon','star');
        $(this).children().children().next().removeClass('ui-icon-custom').addClass('ui-icon-star');
    }).page();
    
    $('#custom-li-2').click(function() {
        $(this).attr('data-icon','home');
        $(this).children().children().next().removeClass('ui-icon-grid').addClass('ui-icon-home');
    }).page();
    
    $('#custom-li-3').click(function() {
        $(this).attr('data-icon','grid');
        $(this).children().children().next().removeClass('ui-icon-star').addClass('ui-icon-grid');
    }).page();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html: <!DOCTYPE html> <html> <head> <script src=http://code.jquery.com/jquery-latest.js></script> </head> <body> <span>not
I have the following code: <!DOCTYPE html> <html> <head> <link rel=stylesheet type=text/css media=screen href=jquery-ui-1.8.9.custom.css
I have the following code <html> <head> <title>Test</title> <style type=text/css> <!-- body,td,th { color:
I have the following HTML code: <?xml version=1.0 encoding=utf-8 ?> <!DOCTYPE html PUBLIC -//W3C//DTD
Let's say I have the following minimalistic HTML code: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
I have the following code. <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> <html
I have the following html code: <h3 id=headerid><span onclick=expandCollapse('headerid')>&uArr;</span>Header title</h3> I would like to
I have the following html.erb code that I'm looking to move to Haml: <span
I have the following code in my file to load a div with HTML
I have a HTML file that has code similar to the following. <table> <tr>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.