I have a phone array that contains data from json:
var phones = [
{
"age": 0,
"id": "motorola-xoom-with-wi-fi",
"imageUrl": "img/phones/motorola-xoom-with-wi-fi.0.jpg",
"name": "Motorola XOOM\u2122 with Wi-Fi",
"snippet": "The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM with Wi-Fi, the world's first tablet powered by Android 3.0 (Honeycomb)."
},
I wrote code to display that array as list ul li:
function createList_Task_4(){
$.each(phones, function(i, phone){
phones.push("<li>" + phone.age +"</li><br><li>" + phone.id +
"</li><br><img src='" + phone.imageUrl + "'/></li><br><li>" + phone.name + "</li><br><li>" + phone.snippet +"</li>" );
});
$('#phonesList').append(phones.join(''));
}
It displays data as I'm want, but on top of the list it displays:
[object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object]
<ul>
<li>0</li>
<li>motorola-xoom-with-wi-fi</li>
<ul/>
How to remove this [object Object]?
phonesis an array of object! What you need? appendlidirectly to$('#phonesList')rather than pushing it tophones.<br>in between<li>s ?