Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to change the color of my headers using Jquery. The following is my code, I can not see where my error is. Please can anyone help me??? I just finished a tutorial in udemy, and I am trying to do some extra problems.


XML
<!DOCTYPE html>
<html>
<head>
<title>Working with Jquery</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>



<style type="text/css">
.red{
    color:red;
    background-color: blue;
}

</style>

</head>
<body>
    <h1>kakjdnjkasn kashdask ajkshdask jdhsajkd hasjkd hsajdkhsajdk asd</h1>
<h1 id="flavio">This is a heading</h1>
<p id="myParagraph">kjshdkas dhaksjdh ajks hdasjkdhas jkdh</p>

<script>
//$('h1').addClass('red');

$('#flavio').css({'background-color': red});

    $("#myParagraph").css({"background-color": "black", "color": "white"});
</script>


</body>
</html>
Posted

The reason was because I was missing http: in my links from google libraries
 
Share this answer
 
Comments
Jafarinejadvazifehkhorani 19-Jun-14 17:22pm    
but I have the same code here , and it's working. anyways good to know that problem is resolved.
the only thing that you need is put red between single quota (')
replace the following with yours


$('#flavio').css({'background-color': 'red'});


that's it
 
Share this answer
 
Comments
Alexander24 19-Jun-14 17:02pm    
I just changed the line you suggested me, but it did not work either

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900