use if/then inside .each loop
hi all,
still a javascript jQuery newbie...
I want to add text inside the .each loop using an if/then statement - not sure how to do it...
basic.
$.each(data, function(key, value) {
console. log ('item', key, value);
output += "<li>" +
value.id + " " + value.name + " " + value.date
+ "</li>";
});
I tried this IF... : but doesn't work...
$.each(data, function(key, value) {
console. log ('item', key, value);
output += "<li>" +
value.id + " " + value.name
if (value.name == "Bob") {
+ " nice name "
}
" " + value.date
+ "</li>";
});
Q: Any idea how to get it to work?
