0
我使用的是動態表(https://puravidaapps.com/table.php2)隨着HTML文檔,我發現如何對錶格的形式從Materializecss.com改變(stripered或鑲上...)在該行:Materialise的CSS改變背景顏色
doc.getElementById("myTable").getElementsByTagName('table')[0].className = "bordered";
但我不知道如何改變不同的顏色。如果我想改變2線的背景顏色,我需要在哪裏寫「卡片面板藍綠色照亮-2」(我有一個包含大量信息的css文件,但我認爲它是materialize.css組件)
謝謝!
<!doctype html>
<head>
<meta name="author" <content="puravidaapps.com">
<meta charset="utf-8">
<meta name="viewport" <content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="materialize.min.css" media="screen,projection"/>
<title>Table Layout</title>
</head>
<body>
<div id="myTable"></div>
<script>
// if you have commas inside your text, feel free to use another delimiter, for example |
var delimiter = ",";
// get the table to display from the window.AppInventor object and split at new line
var urlArray = window.AppInventor.getWebViewString().split("\n");
//var urlArray = location.search.slice(1).split("/n");
var doc = document;
var fragment = doc.createDocumentFragment();
var thead = doc.createElement("thead");
var tr = doc.createElement("tr");
// split at delimiter
var rowArray = urlArray[0].split(delimiter);
addRow(thead, "th");
fragment.appendChild(thead);
var tbody = doc.createElement("tbody");
for(i=1;iurlArray.length;i++){
var tr = doc.createElement("tr");
// split at delimiter
var rowArray = urlArray[i].split(delimiter);
tr.addEventListener ("click", function() {
// return index (add 1 because first row is the header row)
//window.document.title = this.rowIndex + 1;
window.AppInventor.setWebViewString(this.rowIndex + 1);
});
addRow(tbody, "td");
}
fragment.appendChild(tbody);
var table = doc.createElement("table");
table.appendChild(fragment);
doc.getElementById("myTable").appendChild(table);
// http://stackoverflow.com/a/9236195/1545993
doc.getElementById("myTable").getElementsByTagName('table')[0].className = "bordered";
function addRow(dom, tag) {
for(j=0;jrowArray.length;j++){
var el = doc.createElement(tag);
el.innerHTML = rowArray[j];
tr.appendChild(el);
dom.appendChild(tr);
}
}
</script>
</body>
</html>