jQuery UI Widget : Button

This page discusses - jQuery UI Widget : Button

jQuery UI Widget : Button

jQuery UI Widget : Button

     

jQuery UI Widget : Button

Button enhances standard form elements like button, input of type submit or reset or anchors to themable buttons with appropiate mouseover and active styles.

In addition to basic push buttons, radio buttons and checkboxes (inputs of type radio and checkbox) can be converted to buttons: Their associated label is styled to appear as the button, while the underlying input is updated on click.

EXAMPLE :

Button : buttonUI1.html

<!DOCTYPE html>
<html>
<head>
  <link href="http://ajax.googleapis.com/ajax/libs/
jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/
jquery/1.4/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/
jqueryui/1.8/jquery-ui.min.js"></script>
  
  <script>
  $(document).ready(function() {
    $("button").button();
  });
  </script>
</head>
<body style="font-size:62.5%;">
  
<button>Button label</button>

</body>
</html>

Output :

Radio button : buttonUI2.html

<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/
themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/
jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/
jquery-ui.min.js"></script>

<script>
$(document).ready(function() {
$("#radio1").buttonset();
});
</script>
</head>
<body style="font-size:62.5%;">

<div id="radio1">
<input type="radio" id="radio1" name="radio" />
<label for="radio1">Choice 1</label>
<input type="radio" id="radio2" name="radio" checked="checked" />
<label for="radio2">Choice 2</label>
<input type="radio" id="radio3" name="radio" />
<label for="radio3">Choice 3</label>
</div>
</body>
</html>

Output :

Download Source Code

Learn from experts! Attend jQuery Training classes.