Thursday 15 May 2014

jquery - I want my body background image to fade in and fade out every 5 seconds, if not atleast change every 5 seconds -


I've found it but have not been able to customize it on my website. I am new to HTML, Javascript and CSS, so bear with me

I want to change my background from bg0.jpg to bg1.jpg > bg2.jpg and then Bg0.jpg .

I am working on dreamweaver.

My source code is connecting with jquery.js and imagefader.js.

My style.css file is also linked to my source code.

The CSS file is applied to the body background image:

  body {background-image: url (../images / Background / BG0.jpg); Background repeat: do not repeat; Background attachment: fixed; Background position: center; }   

My imagefader.js has the following content:

  (function () {var curImgId = 0; var numberOfImages = 3; // replace it The number of background images in the window.setInterval (function () {$ ('body'). CSS ('background-image', 'url (/ background' + curimgId + '.jpg)'); curImgId = (curImgId + 1) % NumberOfImages;}, 5 * 1000);}) ();   

The problem is that changes in a white background after 5 seconds instead of bg1.jpg from bg0.jpg.

Result can be seen here.

Please help me modify the files so that I can get the necessary results.

The path is wrong

  $ ('body'). CSS ('background-image', 'url (/ background' + curImgId + '.jpg)');   

Your images are ../images/backgrouds/ and the first attempt tries to url.

However, you want:

  $ ('body'). CSS ('background-image', 'url (/ images / background / bg' + curvegid + '.jpg)');   

I can not recommend the intelligence to help with such problems. It shows every HTTP request from your browser so that you can view 404.



No comments:

Post a Comment