I have the following HTML
<!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 navigation bar and change the icon and background for the selected tab (the icon will differ for different tabs).
Using this CSS, I can target the active tab
.ui-btn-active{ background:red !important; }
But I want to target each tab separately, because for each tab I need to select separate selected icons (or, more simply, for the convenience of illustration) I need a different active tab color for each tab: red for the first, blue for the 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 task I ran into is to set the selected state for my custom icon. This is the CSS that 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 canβt figure out how to do this.
source share