仅当电话存在时我将如何进行此附加,如果电话不存在则跳过
for (var i in data.businesses) {
$('body').append( "<p>" + data.businesses[i].telephone + "</p>");
}
仅当电话存在时我将如何进行此附加,如果电话不存在则跳过
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>");
}
});
for (var i in data.businesses) {
if(data.businesses[i].telephone)
$('body').append( "<p>" + data.businesses[i].telephone + "</p>");
}
尝试这个:
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>");
}
}