배열의 상단에 선언 된 search_by_type
입니다. 이제 모든 클릭에서 나는 잘 작동하는 배열에 rest_type_id
값을 설정합니다.배열이 비어 있지 않습니다.
이제 다른 페이지 작업은 get_all_restro()
함수를 호출하여 배열 search_by_type
을 비 웁니다. 다시 restro_type_filter
클래스를 클릭하면 값이 비어 있지 않음을 의미하는 배열이 인쇄됩니다.
var search_by_type = new Array();
$(document).on("click",".restro_type_filter",function(){
console.log(search_by_type);
var rest_type_id = $(this).attr('rest_type_id');
search_by_type.push(rest_type_id);
});
function get_all_restro(type){
search_by_type.length = 0;
}
편집 :() 함수의 get_all_restro에서 오류가
좋아들 -이 어떻게 해결해야 Cannot set property 'length' of undefined
은? 이 오류로 인해 문제가 발생합니까?
여기에 무슨 일이 일어나고 있습니까? 내가 잘못하고있는 것은 무엇입니까?
미리 감사드립니다.
http://stackoverflow.com/questions/206988/how-do -i-unset-in-array-in-javascript –
가능한 복제본을 [JavaScript에서 배열 비우기?] (http://stackoverflow.com/questions/1232040/empty-an-a) rray-in-javascript) – jbutler483
이 오류를 재현 할 수있는 최소한의 바이올린을 만들 수 있습니까? –