Build jQuery UI Button - Icons in JavaScript

Description

The following code shows how to build jQuery UI Button - Icons.

Example


<!-- Revised from demo code on http://jqueryui.com/ -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Button - Icons</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<!-- w  ww  . ja  v  a2 s. c o m-->
<script>
$(function() {
$( "button:first" ).button({
icons: {
primary: "ui-icon-locked"
},
text: false
}).next().button({
icons: {
primary: "ui-icon-locked"
}
}).next().button({
icons: {
primary: "ui-icon-gear",
secondary: "ui-icon-triangle-1-s"
}
}).next().button({
icons: {
primary: "ui-icon-gear",
secondary: "ui-icon-triangle-1-s"
},
text: false
});
});
</script>
</head>
<body>

<button>Button with icon only</button>
<button>Button with icon on the left</button>
<button>Button with two icons</button>
<button>Button with two icons and no text</button>

<div class="demo-description">
<p>Some buttons with various combinations of text and icons.</p>
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Build jQuery UI Button - Icons in JavaScript
Home »
  Javascript Tutorial »
    jQuery UI »
      Button
Javascript Tutorial Button
Build jQuery UI Button - Checkboxes in Java...
Build jQuery UI Button - Default functional...
Build jQuery UI Button - Icons in JavaScrip...
Build jQuery UI Button - Radios in JavaScri...
Build jQuery UI Button - Split button in Ja...
Build jQuery UI Button - Toolbar in JavaScr...