A是总数,B是减,C是余,页面加载后会有A,C,当输入B的时候C变化,问题是
现在输入B后,光标移动到C才会触发onChange事件,我想要的是,输入的同时,C变化
<script type="text/javascript">
$(function(){
$('#A').textbox('setValue', 10);
$('#C').textbox('setValue', $('#A').textbox('getValue'));
$('#B').textbox({
onChange: function (n, o) {
$('#C').textbox('setValue', $('#A').textbox('getValue') - n);
}
});
});
</script>
<input class="easyui-textbox" id="A" style="width:50px" />总
<input class="easyui-textbox" id="B" style="width:50px" />减
<input class="easyui-textbox" id="C" style="width:50px" />余
直接给dom绑定input/propertychange事件
<script type="text/javascript">
$(function () {
$('#A').textbox('setValue', 10);
$('#C').textbox('setValue', $('#A').textbox('getValue'));
function change(n, o) { $('#C').textbox('setValue', $('#A').textbox('getValue') - this.value); }
$('#B').textbox('textbox').bind({ input: change, propertychange: change });
});
</script>
<input class="easyui-textbox" id="A" style="width:50px" />总
<input class="easyui-textbox" id="B" style="width:50px" />减
<input class="easyui-textbox" id="C" style="width:50px" />余
加事件,直接用jquery就好。不是这么写的。