Font awesome and javascript

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

Answers (1)

Sirko
Sirko

Reputation: 74086

  1. You will need innerHTML instead of innerText if you want to add HTML content.
  2. Enclose the content in ".

So your getVal() should look like this:

function getval(cel) {
  cel.innerHTML += "<i class='icon-spinner icon-spin icon-large'></i>";
}

Upvotes: 2

Related Questions