Update button text in click event

Description

The following code shows how to update button text in click event.

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><!--from  w  w  w  .j ava 2s .  com-->
<script type='text/javascript'>
var count = 1;
$("#button").on('click', function () {
    $(this).val("Click Me (" + (count++) + ")").button("refresh");
});
</script>
<body>
  <div data-role="page">
    <div data-role="content">
      <input id="button" type="button" value="Click Me (0)" />
    </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