我想更改所有標題,通常這很容易(並且可能仍然是)。 對我來說,顏色將只取決於數據屬性的propeties,所以我必須先過濾它。這工作,但現在只有我不能在頭上設置CSS。 我得到這個錯誤用jquery更改標題外觀
script.js:175Uncaught SyntaxError: Unexpected string
上:
$("h1").css("border-bottom":"2px solid rgb(255, 0, 0)");
我想我已經與 「H1」 結合$(本),但我不知道怎麼辦。
function setSectionColors() {
// set headlines correct color
var blockIncrement = 1/rows;
for(var i = 0; i < rows; i++) {
var min = i*blockIncrement;
var max = (i+1)*blockIncrement;
// sloppy fix
if(min > 0) {
min += 0.00000001;
}
$(".headline").filter(function() {
return ((parseFloat($(this).attr("data-rating")) >= min) && (parseFloat($(this).attr("data-rating")) <= max));
}).each(function() {
// getRowColor here instand of red
console.log($(this));
$("h1").css("border-bottom":"2px solid rgb(255, 0, 0)");
});
}
}
這是來自console.log($(this))的輸出之一;
<div class="headline" data-rating="0.428688799039" onclick="javascript:showArticle(769);" style="display: none; ">
<h1>Worsteling GroenLinks doet Femke Halsema pijn</h1> <p><p>Oud-partijleider van GroenLinks Femke Halsema ziet haar partij “worstelen”, wat haar “pijn” doet. De worsteling van de partij heeft volgens Halsema ten dele te maken met Jolande Sap, haar opvolgster.</p></p> <hr/>
@hunter哈哈的編輯表示感謝。愚蠢的我:-P – Neal 2012-01-03 17:21:40