这是我的代码,但是在acadyearTo中输出NaN:
jquery:
<script>
$( document ).ready(function() {
var sum = parseInt($('#acadyearFrom').val()) + 1;
$('#acadyearTo').val(sum);
});
</script>
html:
<input type="text" name="acadyearFrom" maxlength="4" id="acadyearFrom">
<input type="text" name="acadyearTo" maxlength="4" id="acadyearTo">
答案 0 :(得分:2)
var sum = parseInt($('#acadyearFrom').val()) + 1; // getting data from one text box, converting into number and adding 1
$('#acadyearTo').val(sum); // setting data to another text box