$.each(segment, function (index, innerSegment)
{
var tr;
for (var i = 0; i < segment.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + <img src="~/Content/left.jpg"/> + + segment[i].Airline.AirlineName + "</td>");
First thing, i am assiging data from $.each loop to a table. In the last line as u can see, i am finding it difficult to assign img src tag in the tr.append tag.
I am missing something in the syntax. please tell me what should i try.
There was a simple problem in showing image in td. Howevere, I have tried all the way to show an image.Finally, this line helped me:
$.each(segment, function(index, innerSegment) {
var tr;
tr = $('<tr/>');
tr.append('<td><img src="../Content/left.jpg"/>' +
innerSegment.Airline.AirlineName + "</td>");
// rest of the code
});
Simply Replacing tilde symbol(~) with (..) did the trick for me
Some error in your code
img
tag is self closing tag and </img>
is invalid. $.each
, so I think for loop can be avoided. $.each(segment, function(index, innerSegment) {
var tr;
tr = $('<tr/>');
tr.append('<td><img src="left.jpg"/>' +
innerSegment.Airline.AirlineName + "</td>");
// rest of the code
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.