我正在使用这个jQuery代码
$('input').bind('change mouseup',... )
检测用户是否将文本拖到我的输入和放大器中改变它的价值.但这似乎不起作用.为什么它不起作用,我怎么能让它工作?
解决方法
var inputField = $("input");
var oldValue = inputField.text();
inputField.bind("drop",function() {
//when the drop happens the input value will not be updated yet
//use a timeout to allow the input value to change.
setTimeout($.proxy(function() {
if (this.value !== oldValue) {
$(this).trigger('change');
}
},this),0);
});
$("input").bind("change",function() {
oldValue = this.value;
});
运行代码:
http://jsfiddle.net/paulwesterberg/FJuvz/5/