Change button background

Description

The following code shows how to change button background.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.3.js'></script>
<script type="text/javascript"
  src="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.css">
<style type='text/css'>
.R {<!-- ww  w.j av a  2  s . co m-->
  background: red;
}

.B {
  background: blue;
}

.G {
  background: green;
}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$('input[name=rdColor]').change(function() {
    $(this).next().addClass($(this).val());
});
});//]]>  
</script>
</head>
<body>
  <div data-role="page" id="home">
    <div data-role="content">
      <div data-role="fieldcontain">
        <fieldset data-role="controlgroup" data-type="horizontal">
          <input type="radio" name="rdColor" id="rd1" value="R" /> 
          <label for="rd1">Red</label> 
          <input type="radio" name="rdColor" id="rd2" value="G" /> 
          <label for="rd2">Green</label> 
          <input type="radio" name="rdColor" id="rd3" value="B" /> 
          <label for="rd3">Blue</label>
        </fieldset>
      </div>
    </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