Get button text
Description
The following code shows how to get text from button and set the value to input text element.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!--from w w w . ja v a 2 s . c om-->
$("button").click(function() {
var text = $(this).text();
$("input").val(text);
});
});
</script>
</head>
<body>
Press button to fill the text box.
<div>
<button>A</button>
<button>B</button>
<button>C</button>
</div>
<input type="text" value="click a button" />
</body>
</html>