假設我只想將其中包含單詞「Blog」的行更改爲綠色或藍色。看看我在jsfiddle中的例子。有沒有辦法改變引導表的行顏色取決於其內容? :P如何根據其內容更改bootstrap-tabe行背景
查看jsfiddle
function rowStyle(row, index) {
var classes = ['active', 'success', 'info', 'warning', 'danger'];
if (index % 2 === 0 && index/2 < classes.length) {
return {
classes: classes[index/2]
};
}
return {};
}
<table data-toggle="table"
data-url="/gh/get/response.json/wenzhixin/bootstrap-table/tree/master/docs/data/data1/"
data-row-style="rowStyle">
<thead>
<tr>
<th data-field="name">Name</th>
<th data-field="stargazers_count">Stars</th>
<th data-field="forks_count">Forks</th>
<th data-field="description">Description</th>
</tr>
</thead>
</table>
請參閱問題中的jsfiddle鏈接以獲得更好的輸出結果。 – NinjaShawarma
就個人而言,我會使用Knockout JS之類的東西,並使用css綁定來根據包含的數據更改顏色。完全動態。 – Korgrue