除了在jQuery的.val()中使用回调之外,还有其他选择吗? [英] Is there an alternative to using a callback inside of jQuery's .val()?
本文介绍了除了在jQuery的.val()中使用回调之外,还有其他选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要在jQuery的.val()方法中使用回调方法的替代方法(显然它不支持).例如:
I would like an alternative to using callback method inside of jQuery's .val() method (Which it clearly doesn't support). For example:
http://jsbin.com/ilahan/edit#source
$("#box").val("The New Value", function(){
alert("It's changed now");
});
推荐答案
使用 .change 吗?
$("#box").val("The New Value").change(function(){
alert("It's changed now");
});
正如Vega在他的评论中所述,无论如何,从代码更改val都不会触发更改事件: 查看全文