Reputation: 893
I am trying to create image tag string in javascript. This image tag in part of table row string. At the end I will append this table row string to mvc webgrid using jquery.
I have a javascript function which returns this new row
function getNewRow(email, friendlyName) {
var imgSrc = "/Content/Images/User.png";
// Create the new row html
var newRow = '<tr class=\"' + rowClass + '\">' +
'<td><text><img src\"' + imgSrc + '\"></text></td>' +
'<td>' + email + '</td>' +
'<td>' + friendlyName + '</td>' +
'</tr>'
return newRow;
}
I will append returned string to webgrid object.
// Append the new Row
$('#group').append(newRow);
But the image tag is not showing proper image. The forward slash is removed after appending. Used encodeURIComponent function but no use. How to make it to show the image properly.
Upvotes: 0
Views: 1914
Reputation: 1157
It seems that you have a typo in the second line of newRow declaration, you are missing the = sign after src attribute
Upvotes: 1
Reputation: 3217
You have <img src\"' + imgSrc + '\"></text></td>
when it should be <img src=\"' + imgSrc + '\"></text></td>
. Notice the missing =
.
Upvotes: 1