2014-02-20 100 views
0

我的HTML代码滑块的Html滑块不工作

<div id="slideshow"> 
    <div> 
    <img src="5658667829_2bb7d42a9c_m.jpg"> 
    </div> 
    <div> 
    <img src="5638093881_a791e4f819_m.jpg"> 
    </div> 

我的CSS代码为滑块

#slideshow { 
    margin: 50px auto; 
    position: relative; 
    width: 240px; 
    height: 240px; 
    padding: 10px; 
    box-shadow: 0 0 20px rgba(0,0,0,0.4); 
} 
    #slideshow > div { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    right: 10px; 
    bottom: 10px; 
} 

我的jQuery代码为滑块

$("#slideshow > div:gt(0)").hide(); 
    setInterval(function() { 
    $('#slideshow > div:first') 
    .fadeOut(1000) 
    .next() 
    .fadeIn(1000) 
    .end() 
    .appendTo('#slideshow'); 
}, 3000); 

这是我的滑码这不起作用,请帮忙。

+0

你使用jquery.ui.slider? – user2167382

+0

否我应该在哪里得到它 –

+0

你检查了浏览器控制台是否有任何javascript错误? – SFIntegrator

回答

1

它为我工作。 您错过了幻灯片div的结束标记。 无论是我的代码是belove

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title>slider</title> 
     <script src="jquery-1.8.3.js" type="text/javascript"></script> 
     <script type="text/javascript"> 
      $(document).ready(function() { 
        $("#slideshow > div:gt(0)").hide(); 
          setInterval(function() { 
          $('#slideshow > div:first') 
          .fadeOut(1000) 
          .next() 
          .fadeIn(1000) 
          .end() 
          .appendTo('#slideshow'); 
         }, 3000); 
      }); 
     </script> 
     <style> 
       #slideshow { 
    margin: 50px auto; 
    position: relative; 
    width: 240px; 
    height: 240px; 
    padding: 10px; 
    box-shadow: 0 0 20px rgba(0,0,0,0.4); 
} 
    #slideshow > div { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    right: 10px; 
    bottom: 10px; 
} 
     </style> 
    </head> 
     <body> 
      <div id="slideshow"> 
    <div> 
    <img src="123.jpg"> 
    </div> 
    <div> 
    <img src="321.jpg"> 
    </div> 
</div> 
     </body> 
    </html> 
+0

thnx求助.. –

+0

@坦桑最欢迎.. – next2u

0

尝试使用文档准备好您的jQuery代码