BlueFireMedia
BlueFireMedia

Reputation: 13

Using jQuery to Edit Body

Well I'm trying to make jQuery edit my body when a link is clicked. So far, all that it does is make the Link Fade but background wont change on the I don't understand why, maybe you guys can help with that.

    <div id="navbar_wrapper">
        <div id="nav_title">
            Kitty <small> "<? echo $information[array_rand($information)]; ?>" </small>
        </div>
        <div id="nav_links">
            <a href="#">Home</a>
            <a href="#">Information</a>
            <a href="#">Contact</a>
            <a href="#" id="activate">Download</a>
        </div>
    </div>


<script type="text/javascript">
 $('#activate').click(function(){
    $(this).fadeOut()
    $('body').css('background: red;')
 });
 </script>

Upvotes: 0

Views: 252

Answers (2)

Jai
Jai

Reputation: 74738

change to this:

$('body').css('background', 'red')

if you want to do then you can choose this in the callback function in the fadout()

$(this).fadeOut('slow', function(){
   $('body').css('background', 'red');
});

Upvotes: 3

DaniP
DaniP

Reputation: 38252

Your code is wrong to make use of the property css you need this structure:

$('body').css('background' , 'red')

The structure is related to :

.css('propertyname' , 'propertyvalue') 

Check more here

Upvotes: 2

Related Questions