I'm puzzled why my very easy script doesn't work. I want to write text into an input field when pressing a button, simple as that :)
Right now I have this:
<input type="button" class="plan-button" id="button15" value="충전" />
and my jQuery:
$('#button15').click(function() {
$('input').val($('input').val() + 'sample text');
});
Without the click event, using only this line:
$('input').val($('input').val() + 'more text');
This works fine. So the problem is the click event? I triple checked for errors... Help would be very much appreciated! Thanks!
EDIT: Here is the rest of the page... I excluded some of the identical table rows to make it easier to read.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$('#button15').click(function() {
$('input').val($('input').val() + 'more text');
});
});
</script>
<table id="mytable" border="0" style="margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td style="text-align: center;">
<div class="box"> <input type="button" class="plan-button" id="button15" value="충전" /></div>
</tbody>
</table>