1
我有一個JavaScript函數來改變某些細胞的背景顏色在HTML表格添加span標籤用JavaScript函數的HTML表格
<script language="javascript">
function GetAllValues() {
var tbl = document.getElementById("monitor");
for (var i = 0; i < tbl.rows.length; i++){
if (parseInt(tbl.rows[i].cells[6].innerHTML) == 1){
tbl.rows[i].cells[5].style.backgroundColor = "green";
}else if (parseInt(tbl.rows[i].cells[6].innerHTML) == 2){
tbl.rows[i].cells[5].style.backgroundColor = "yellow";
}else if (parseInt(tbl.rows[i].cells[6].innerHTML) == 3){
tbl.rows[i].cells[5].style.backgroundColor = "red";
}else if (parseInt(tbl.rows[i].cells[6].innerHTML) == 5){
tbl.rows[i].cells[5].style.backgroundColor = "gray";
}else{
tbl.rows[i].cells[5].style.backgroundColor = "white";
}
</script>
但我需要一個「跨度」標籤添加到值像這樣的單元格:
<span class="label label-success">table cell value</span>
我不知道如何將此標記添加到單元格中。
你能給我帶來一些片段或鏈接,我可以採取一些想法。
在此先感謝
謝謝兄弟真的很有幫助 – Joseleg 2014-09-03 00:21:03