私のフォームでは、サーバーからロードされた後に変更された値を確認するだけです。そのために私はこの機能をやっています:
$(checkBox).each(function(i,el){
status.push($(el).prop("checked"));
$(el).click(function(){
var clickedIndex = checkBox.index($(this));
var prevStatus = status[clickedIndex];
if(prevStatus !== $(this).prop("checked")){
statusChanged.push($(this).val() + ( $(this).prop("checked") ? add.toLowerCase() : remove.toLowerCase()));
}else{
var that = $(this);
statusChanged = $.grep(statusChanged, function(value) {
return value != that.val() + add.toLowerCase()
});
statusChanged = $.grep(statusChanged, function(value) {
return value != that.val() + remove.toLowerCase()
});
}
console.log(statusChanged);
})
})
この関数では、else 部分 (statusChanged) で $.grep 関数を 2 回呼び出してい"add"
ます"remove"
。
var that = $(this);
statusChanged = $.grep(statusChanged, function(value) {
return value != that.val() + add.toLowerCase() || that.val() + remove.toLowerCase() //not working
});
動作していません..?ここで何が問題なのか、または $,grep は or (||) 三項演算子を受け入れないか、他の短い方法を指定します.. pls
前もって感謝します。