내 양식에서 서버에서로드 된 값이 변경되었습니다. 나는이 같은 기능을 작성하는 경우 (경우 - 다른 부분 (statusChanged) 내가 $ .grep 기능을 "add"
및 "remove"
로 2 회를 호출 오전에이 기능에
$(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);
})
})
: 그것을 위해 나는이 기능을하고있는 중이 야 그 부분 만)
var that = $(this);
statusChanged = $.grep(statusChanged, function(value) {
return value != that.val() + add.toLowerCase() || that.val() + remove.toLowerCase() //not working
});
작동하지 않습니까? 여기 또는 $, grep은 (또는 ||) 삼항 연산자를 수락하지 않거나 다른 하나의 짧은 메서드를 제공합니다. pls
감사합니다.