1

How can i add fontawesome icons to a button generated like this?

$.each(response, function (i, item) {
trHTML += '<tr><td>' + item.name + '</td><td>'  + "<input 
type='button' onclick='getTxtUrl(" + item.id + ")' style = 'width: 
32px; height: 28px;' class='btn btn-success'>" + '</td></tr>';
});

I've tried so many things and am going crazy. I'm sure it will turn out to be the stupidest thing, missing a ' or something. Help please!

  • Yes ir was quotes `$.each(response, function(i, item) { trHTML += '' + item.name + ''; });` – mplungjan Jun 25 '19 at 09:44
  • This is easier to read and can have breaklines `$.each(response, function(i, item) { trHTML += \`${item.name}\`; });` – mplungjan Jun 25 '19 at 09:50

1 Answers1

2

Use button instead of input type button

$.each(response, function (i, item) {
                trHTML += '<tr><td>' + item.name + '</td><td>'  + "<button onclick='getTxtUrl(" + item.id + ")' style = 'width: 32px; height: 28px;' class='btn btn-success'><i class='fa fa-check'></i></button>" + '</td></tr>';
            });
Radonirina Maminiaina
  • 6,958
  • 4
  • 33
  • 60