jQuery.each(input, function(key, value){
jQuery('<div/>', {
class: 'info',
id: value.id,
text: jQuery('<div/>', {class: 'image', text: '<img src="'+value.image+'">'})+jQuery('<div/>', {class: 'text_data', text: value.name})
}).appendTo('#list');
});
Is it possible somehow to convert objects to string in text attribute (should to be no cycles). If needed can be wrapped by a function.
UPDATE:
<div class="info" id="29">[object Object][object Object]</div>
<div class="info" id="30">[object Object][object Object]</div>
<div class="info" id="31">[object Object][object Object]</div>
So i need to update this line jQuery('<div/>', {class: 'image', text: '<img src="'+value.image+'">'})+jQuery('<div/>', {class: 'text_data', text: value.name}) that there would be a string.
I’ll expand on Rachel’s answer
You are creating two elements here
To get it as a string.. create an container element and append those two elements.. so you can get it back as a html string by calling .html()