Stránka 1 z 1

JS - Slider

Napsal: 25 dub 2014 22:33
od Fir3stPlays
Zdravím,

na webu mam nastylovaný slider.

Kód: Vybrat vše

<script type="text/javascript" async="" src="./Firest_files/ga.js"></script><script src="./Firest_files/jquery.min.js"></script>
   <script>
   var photos = ["images/header1.jpg","images/header2.jpg","images/header3.jpg","images/header4.jpg","images/header5.jpg","images/header6.jpg","images/header7.jpg"];
   var current = 0;
   function slideshow() {
      $('#header').animate({ opacity: 0 }, 800, function() {
         $('#header').css("background-image", "url("+photos[current]+")");
         $('#header').animate({ opacity: 1 }, 800);
      });
      if(current == photos.length-1) {
         current = 0;
      } else {
         current++;
      }
   }
   $(document).ready(function() {
      interval = setInterval(function() {slideshow();}, 4000);
   });
   </script>

ale na webu se mi nezobrazuje mam ho v body a v divu, někde jsem četl, že by se slider měl dávat do headu, ale přijde mi to jako blbost.

S pozdravem, Michal Firest

Re: JS - Slider

Napsal: 26 dub 2014 15:19
od LuCaCZ
ten kód co si sem dal patří mezi tagy <header> a samotný <div id="header"></div> do <body>

#header musí mít nastylovanou výšku a šířku ... samozřejmostí jsou správně umístěné soubory jquery.min.js a obrázky