I have a table whose data gets changed dynamically. If a particular condition is satisfied, then I want to show an image and if not then another image.
I used unicode, but it was too small and the png file is too large.
Here is the code
if (game['B'] != game['A'])
$('<img>').attr('src','symbol.png').appendTo(tr);
//$('<td></td>').text("\uD83D\uDC4D").appendTo(tr);
else
$('<td></td>').text("\uD83D\uDC4E").appendTo(tr);
How can I change the size of it through here?
Any kind of help would be appreciated. Thanks.
Usually, you would use CSS. But there is a way to do what you're asking right there to make things neat... Let's assume you what the width of the pic to be 100px, here's what you would use (untested). For a complete list of CSS properties available, which can be used with the added .css field, please refer to: https://www.w3schools.com/cssref/
if (game['B'] != game['A']) {
$('<img>').attr('src','symbol.png').css('width', '100px').appendTo(tr);
} else {
$('<td></td>').text("\uD83D\uDC4E").appendTo(tr);
}
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.