Reputation: 109
jQuery is creating a div like this
document.write("<div class='post' id=''>");
document.write(postcontent);
document.write(json.feed.entry[i].id.$t);
document.write('</div>');
But I want to move (json.feed.entry[i].id.$t) into the id of the div like this
document.write("<div class='post' id='(json.feed.entry[i].id.$t)'>");
document.write(postcontent);
document.write('</div>');
Cant get the syntax right as the above example does not work..
Upvotes: 0
Views: 33
Reputation: 15501
You arent concatenating correctly. Do it this way:
document.write("<div class='post' id='"+(json.feed.entry[i].id.$t)+"'>");
Upvotes: 1
Reputation: 82241
You have not handled the quotes correctly while setting id value. use:
document.write("<div class='post' id='"+json.feed.entry[i].id.$t+"'>");
document.write(postcontent);
document.write('</div>');
You can also narrow down document.write to be used only once:
document.write("<div class='post' id='" + json.feed.entry[i].id.$t + "'>" + postcontent + "</div>");
Upvotes: 1