Toggle button text
Description
The following code shows how to toggle button text.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.5.2.js'></script>
<script type='text/javascript'
src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css">
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!-- ww w . j a va2 s. c o m-->
$('#abutton').toggle(function(){
setAButtonText("New Text For A Button");
}, function(){
setAButtonText("Do Stuff");
});
$('#myButton').toggle(function(){
setInputButtonText("New Text For Input Button");
}, function(){
setInputButtonText("My Value");
});
function setInputButtonText(txt){
$("#myButton").prev('a').find('span.ui-btn-text').text(txt);
}
function setAButtonText(txt){
$('#abutton .ui-btn-text').text(txt);
}
});//]]>
</script>
</head>
<body>
<div data-role="page">
Click on the buttons
<a href="#section" id="abutton"
data-role="button">Do Stuff</a>
<input type="button" name="answer"
id="myButton" value="My Value" data-role="button" />
</div>
</body>
</html>