이 기능이 왜 작동하지 않는지 알고 계십니까?
나는 창을 사용하여 전역 배열의 값을 검색합니다. console.log를 사용하여 arr 객체 값을 얻습니다. 하지만 foreach에서 arr 객체를 사용하려고하면 코드가 손상됩니다. 이유가 무엇입니까?
function setDropDownList(raw_id, val){
// Get the ID
var the_id = '#'+raw_id;
// Get the array name as a string
var arrname = val+"Array";
// get the arr object using the arrname string
var arr = window[arrname];
// if I place a console.log here, i get the values for the arr object, but it brakes the .each below:
// do a simple foreach
// using arr breaks the foreach loop
// if I use the actual array declared globally in he header it works.
jQuery.each(arr, function(key, value) {
var test = value.split('|');
});
}
"깨지다"는 것은 무엇을 의미합니까? '.each'에서는 어떻게됩니까? *'console.log (arr)'은 무엇을 인쇄합니까? –
실제로 어떻게 깨지나요? –
console.log (arr)는 $ .each가 없으면 arr 객체를 잘 보여줍니다. 루프를 수행 할 때 arr에 대한 console.log()는 다음을 보여줍니다. undefined – user2065483