-1
嗨,大家好,我从网络获得了以下代码并根据需要进行了修改,但未按预期工作。如何使用jQuery单击取消按钮时恢复下拉选择选项?
var lastValue;
$("#changer").bind("click", function(e){
lastValue = $(this).val();
}).bind("change", function(e){
changeConfirmation = confirm("Really?");
if (changeConfirmation) {
// Proceed as planned
} else {
//$(this).val(lastValue);
DummyFun();
}
});
function DummyFun()
{
alert(lastValue);
$(this).val(lastValue);
}
这里是我从哪里得到的代码,它工作正常fiddle。我怎样才能让我的工作像小提琴一样工作?