0

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>;
        }
4

1 回答 1

2
  1. 如果要添加 HTML 内容,您将需要innerHTML而不是。innerText
  2. 将内容附在".

所以你getVal()应该看起来像这样:

function getval(cel) {
  cel.innerHTML += "<i class='icon-spinner icon-spin icon-large'></i>";
}
于 2013-09-05T13:21:11.860 回答