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

久未见 提交于 2019-12-23 01:16:06

问题


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


回答1:


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>



回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/1742659/how-to-changing-my-background-image-css-property-using-mootools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!