Put a Javascript variable into a innerHTML code

前端 未结 2 1649
伪装坚强ぢ
伪装坚强ぢ 2021-01-02 12:44

I\'m creating a table dynamic table with Javascript:

var row = table.insertRow(-1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 =         


        
相关标签:
2条回答
  • 2021-01-02 13:00

    Use "+".

    var add = aux[i].split("#");
    cell5.innerHTML = "<img src='MatrixLogos/"+add[3]+"' width='100' height='25'/>";
    
    0 讨论(0)
  • 2021-01-02 13:02

    Use String concatenation like

    var add = aux[i].split("#");
    var string = "This is to " + add[3] + " test with value";
    

    Where as in your case, statement will become:

    cell5.innerHTML = "<img src='MatrixLogos/"+add[3]+"' width='100' height='25'/>";
    
    0 讨论(0)
提交回复
热议问题