가 어떻게jQuery를
for (var i in data.businesses) {
$('body').append("<p>" + data.businesses[i].telephone + "</p>");
}
가 어떻게jQuery를
for (var i in data.businesses) {
$('body').append("<p>" + data.businesses[i].telephone + "</p>");
}
이
$.each(data.businesses, function(index, business){
if(business.telephone){
$('body').append("<p>" + business.telephone + "</p>");
}
});
이 시도하려고 전화가있는 경우에만이 APPEND을하고 전화가없는 경우 건너 뛸 것이라고 정의 된 경우 추가 :
for (var i in data.businesses) {
if(data.businesses[i].telephone !== null and data.businesses[i].telephone !== undefined) {
$('body').append("<p>" + data.businesses[i].telephone + "</p>");
}
}
[이것은 속성의 존재를 확인하기위한 훌륭한 기사입니다.] (http://www.nczonline.net/blog/2010/07/27/determining-if-an-object-property-exists/) –
for (var i in data.businesses) {
if(data.businesses[i].telephone)
$('body').append("<p>" + data.businesses[i].telephone + "</p>");
}
을
전화 란 무엇입니까? –
가능한 중복 jQuery에 대한 "존재"기능이 있습니까?] (http://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery) –
당신은'if'에 대해 알고 있습니다. /'else' 나는 추정한다. [ "자바 스크립트에서 객체의 속성을 확인하려면 어떻게해야합니까?"(http://stackoverflow.com/questions/135448/how-do-i-check-to-see-home.html) if-an-object-has-a-property-in-javascript) 또는 for..in 때문에 사용하지 못할 수도 있습니다. http://stackoverflow.com/questions/500504/why-is-using-for-in-with-array-iteration-such-a-bad-idea –