나는 특정 주소에 값을 제거하려는 개체에서 일하고 있습니다. 내가 요소의 위치를 필요로하고 여기
객체
에서 제거 할 코드 :var matches = {
"users-email": "email",
"users-activated": "activated",
"users-created_at": "created_at",
"users-registration_page": "registration_page",
"profiles-firstname": "firstname"
} ;
var option = 'firstname';
var if_in = $.inArray(option, matches);
//console.log(matches)
if(if_in !== -1)
{
matches.splice(if_in, 1);
}
$.each(matches , function(i,v){
$('.test').append(v+'<br>');
});
내 객체의 $.inArray()
가 반환 작동하지 -1.
누군가이 나를 찾을 수 있도록 도와 줄 수 있습니까?
당신의 일치 변수가 객체가 아닌 배열 방식으로 값을 확인하는 것입니다 . – vaso123
@Alexander 옵션이 핵심 일 경우에만 작동합니다. 이 경우 값은 –
입니다.'$ .inArray'는 배열에서만 작동합니다. 'matches'는 배열이 아닙니다. –