Toggle button class

Description

The following code shows how to toggle button class.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://jquerymobile.com/demos/1.2.0/css/themes/default/jquery.mobile-1.2.0.css">
<script type='text/javascript'
  src="http://jquerymobile.com/demos/1.2.0/js/jquery.mobile-1.2.0.js"></script>
<style type='text/css'>
.someRedStuff {<!--  ww  w.  ja  v  a  2 s. c  o  m-->
  background: red !important;
}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
    $('#custom-li-3').on('click', function(event){
        $(this).toggleClass('someRedStuff');
    });
});//]]>  
</script>
</head>
<body>
  <div data-role="page" class="type-home">
    <div data-role="content">
      <a data-role="button" data-iconpos="notext" data-icon="star"
        id="custom-li-3"></a>
    </div>
  </div>
</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