Set active button with ui-btn-active

Description

The following code shows how to set active button with ui-btn-active.

Example


<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
  href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script
  src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
</head><!--  w  ww  .  j  av  a2s .  co  m-->
<body>
  <div data-role="page">
    <div data-role="content">
      <ul data-role="listview">
        <li><a class="ui-btn-active" href="#">Click</a></li>
        <li><a href="#">Me</a></li>
        <li><a href="#">OR</a></li>
        <li><a href="#">Me</a></li>
      </ul>
    </div>
  </div>
<script type='text/javascript'>//<![CDATA[ 
$('ul').find('a').on('click', function () {
    $(this).closest('ul').find('a').removeClass('ui-btn-active');
    $(this).addClass('ui-btn-active');
});
</script>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme