$('input[name=test1]').keyup(function(){console.log(1)}).change(function(){console.log(2)})

解决方案 »

  1.   

    把 blur 改为 propertychange
      

  2.   

    换成你的函数
     $('input[name=test1]').keyup(f).change(f)
      

  3.   

    把if(a.keyCode==13)删除就实时监听了。
    不过提示错误就好不要用alert('错误!');不然总是弹对话框。
      

  4.   

    换成你的函数
     $('input[name=test1]').keyup(f).change(f)我想要的效果就是test1+test2=test3  3个input实时监听test1和test2,当test3的值=0的时候,test3的背景颜色变成红色。