clankill3r
clankill3r

Reputation: 9543

change header look with jquery

I want to change all headers, normally this is quite easy (and it probably still is). By me the color will only depend on propeties of the data attribute so i have to filter it first. That works but now only i can't set the css on the headers. I get this error

script.js:175Uncaught SyntaxError: Unexpected string

on:

$("h1").css("border-bottom":"2px solid rgb(255, 0, 0)");

I think i have to combine $(this) with the "h1" but i don't know how.

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)");
        });

    }
}

this is one of the outputs from 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 &#8220;worstelen&#8221;, wat haar &#8220;pijn&#8221; doet. De worsteling van de partij heeft volgens Halsema ten dele te maken met Jolande Sap, haar opvolgster.</p></p>                       <hr/> 

Upvotes: 2

Views: 170

Answers (2)

Ya Zhuang
Ya Zhuang

Reputation: 4660

//$("h1").css("border-bottom" , "2px solid rgb(255, 0, 0)");
                              here!

Upvotes: 1

Naftali
Naftali

Reputation: 146310

Use a comma:

$("h1").css("border-bottom","2px solid rgb(255, 0, 0)");

Or use an object:

$("h1").css({"border-bottom":"2px solid rgb(255, 0, 0)"});

Upvotes: 6

Related Questions