Hello,

What's the php code for changing css body background?.

If you press this button then, css body background changes. What to code it?

Recommended Answers

All 2 Replies

You wouldn't do this with PHP, you would do it with Javascript. You should check out the jQuery library. If you were to use jQuery, you would do it like this: $('body').css('background-color', 'blue');. You would need to be using the jQuery library though.

index.php

<script type="text/javascript">
$('#slideshow').cycle({ 
    fx:     'fade', 
    speed:   900, 
    timeout: 10000, 
    pager:  '#nav', 
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#nav li:eq(' + idx + ') a'; 
    } 
});
</script>


<div id="demos">
    <div id="slideshow" class="pics">
        <script>$('body').css('background-color', 'blue');</script>
        <script>$('body').css('background-color', 'red');</script>
        <script>$('body').css('background-image', 'url("../images/indonusa3.jpg")');</script>        
    </div>
    <ul id="nav">
        <li><a href="#"></a></li>
        <li><a href="#"></a></li>
        <li><a href="#"></a></li>   
    </ul>
</div>

The background navigation button keeps rolling, I can see a changing css text code on the left; yet, the background color is red with no images.

My goal is to have body background images changing along with the navigation button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.