Reputation: 3665
I'm trying to add a spinner to the text of a table cell, once it is clicked. I'm using Font Awesome as my spinner, but I can't seem to figure out how to add the spinner in the javascript. I'm guessing it have something to do with the i class
, but I can't seem to figure it out. Code below
var tbl = document.getElementById("table");
if (tbl != null) {
for (var i = 1; i < tbl.rows.length; i++) {
for (var j = 0; j < tbl.rows[i].cells.length; j++)
tbl.rows[i].cells[j].onclick = function () {getval(this); };
}
}
function getval(cel) {
cel.innerText += <i class='icon-spinner icon-spin icon-large'></i>;
}
Upvotes: 0
Views: 387
Reputation: 74086
innerHTML
instead of innerText
if you want to add HTML content. "
.So your getVal()
should look like this:
function getval(cel) {
cel.innerHTML += "<i class='icon-spinner icon-spin icon-large'></i>";
}
Upvotes: 2