除了在 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");
});
推荐答案
$("#box").val("The New Value").change(function(){
alert("It's changed now");
});
<小时>
正如 Vega 在他的评论中所说的那样,无论如何更改代码中的 val 都不会触发更改事件:.val() 不会在 jquery 中触发 .change()
这篇关于除了在 jQuery 的 .val() 中使用回调之外,还有其他选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文