javascript - jQuery appends blank (nothing) when concatenating -
i have html
<html> <head> <script src="js/vendor/jquery-1.10.1.min.js"></script> <script src="js/rest.js"></script> </head> <body> <table> <tbody id="list"></tbody> </table> </body> </html>
and js
$(document).ready(function(){ var url = 'js/context.xml' requestxml(url); }); function requestxml(url){ $.ajax({ type: "get", url: url, datatype: "xml", success: function(xml){ var items = $(xml).find('item'); $.each(items, function(){ var id = $(this).text(); $('#list').append('<tr>'+id+'</tr>'); //$('#list').append(id); console.log(id); }); } }); }
when check source generated this, , blank. console shows id. if remove tags shows me ids.
what problem , how fix this.
as tymejv said: put id
s <td>
s first , <tr>
s:
$('#list').append('<tr><td>'+id+'</td></tr>');
Comments
Post a Comment