efoc
efoc

Reputation: 21

How to changing my background-image css property using Mootools?

I am newbie。 How to changing my background-image css property using Mootools?

Upvotes: 2

Views: 8663

Answers (3)

Oskar Krawczyk
Oskar Krawczyk

Reputation: 3502

window.addEvents({
  // fire when the DOM is loaded
  domready: function(){
    // path to the image
    var pathToBackgroundImage = '/path/to/the/image.jpg';
    // set the background-image
    $(document.body).setStyle('background-image','url(' + pathToBackgroundImage + ')');
  }
});

You need to take a significantly different approach if you decide you'd like to fade-in the image.

Upvotes: 1

Piotr Rochala
Piotr Rochala

Reputation: 7781

Example, on page load:

<div id="yourElement"></div>

<script type="text/javascript">
window.addEvent('domready', function() {
    $('yourElement').setStyle('background-image', 'url(path/to/your/image)');
});
</script>

Upvotes: 7

saleemshafi
saleemshafi

Reputation: 1161

The MooTools docs for Element.Style should be able to answer this one for you.

Upvotes: 2

Related Questions