【发布时间】:2015-09-18 19:28:05
【问题描述】:
我目前正在尝试将这些按钮放入我的 HTML 表格中。
这是我要插入的代码:
<button class=\"btn btn-primary btn-xs my-xs-btn\" type='button' onClick='changeRec(".$num.")' >
<span class=\"glyphicon glyphicon-pencil\"></span> Edit
</button>
这是我插入它的尝试。
<button type="button" class="btn btn-primary btn-lg" onclick="myFunction()">Add</button>
<script>
function myFunction() {
var table = document.getElementById("myTable");
var row = table.insertRow(-1);
var cellInstruction = row.insertCell(-1);
cellInstruction.innerHTML = '<button class=\"btn btn-primary btn-xs my-xs-btn\" type='button' onClick='changeRec(".$num.")' >
<span class=\"glyphicon glyphicon-pencil\"></span> Edit
</button>';
}
</script>
任何帮助将不胜感激。谢谢!
【问题讨论】:
-
脚本中的
cellInstruction是什么? -
抱歉,我发帖的时候漏掉了一行代码。 cellInstruction 是单元格。
-
现在,
row是什么? -
我真的搞砸了抄写代码。我再次对代码进行了更改。行只是新行。
标签: html html-table htmlbutton