일부 요소의 값에() .join 호출 할 수 없습니다 : 그것은 내가 이렇게 설정 변수 <code>selectedTagNames</code>있어
var selectedTagNames = $(".js-tag-name:checked").map(function(){return $(this).val()});
selectedTagNames
=> ["song:age_suitability=11-13", "song:age_suitability=5-7"]
배열로 나타납니다. 내가 가진 '||'하나의 문자열로 값에 가입하고 싶지만 그럴 수 없어 :
var searchTerm = selectedTagNames.join('||')
=> VM7234:2 Uncaught TypeError: undefined is not a function
message: "undefined is not a function"
stack: (...)get stack: function() { [native code] }
set stack: function() { [native code] }__proto__: Error
내가 오히려 변수를 사용하는 대신 수동으로 작업을 수행 할 수 있습니다 그래서
["song:age_suitability=11-13", "song:age_suitability=5-7"].join('||')
=> "song:age_suitability=11-13||song:age_suitability=5-7"
을, 변수의 값은 두 번째 예제에서 사용하는 배열과 달라야합니다 (동일한 것으로 보일지라도). 둘 다 typeof()
에 대해 '개체'를 반환합니다.
jquery 버전 1.7.1을 사용하고 있습니다.
아무도 말해 줄 수 있습니까 a) 여기 무슨 일이 있습니까? b) 선택된 체크 박스의 값을 배열로 모으는 방법, 그래서 거기에 몇 개가 있는지 알 수 있으며 함께 결합하여 여기에 잘못되어있는 것을 피할 수 있습니까?
아! .. 정크 스! 허용되는 한 빨리 수정 표시 : –
도와 드리겠습니다. – Utkanos