使用 jQuery 循环插件循环浏览 div



我正在尝试循环浏览一些通过wordpress动态生成的div。

无论我尝试什么,div 都不会循环或滑动,我也不知道为什么。

源代码当前如下所示:

<div class="slider">
    <div class="servicesslider">    
           <a href="link1">
            <div class="slidertext">
               <h1 class="sliderhead">Text1</h1>
                <p>Body copy</p>
            </div>  
    <img width="450" height="270" src="imglink" class="attachment-front-page-services wp-post-image" alt="alt" title="title" />                     
            </a>
    </div>

   <div class="servicesslider"> 
      <a href="link2">
         <div class="slidertext">
        <h1 class="sliderhead">Text2</h1>
        <p>More body copy.</p>
         </div>
      <img width="450" height="270" src="imglink" class="attachment-front-page-services wp-post-image" alt="alt" title="title" />
       </a>
    </div>

.CSS:

.slider {width:1000px; height:400px; overflow:hidden; position:relative;}
.servicesslider {width:900px; height:300px; padding:50px; overflow:hidden; float:left; position:absolute; background:red;}
.servicesslider a {text-decoration:none;}
.attachment-front-page-services {width:450px; height:270px; background:#fff; border:10px solid #fff; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; box-shadow: 5px 5px 7px #4f4f4f;}
.slidertext {font-family: Eurostyle; color:#ffffff; text-decoration:none; float:left; margin-right:20px; width:400px;}
.sliderhead {font-size:50px;}
.sliderhead a {color:#ffffff; text-decoration:none;}

jQuery(使用最简单的版本只是为了得到任何事情发生)

<script type="text/javascript">
    $(document).ready(function () {
        $('.slideshow').cycle({
            fx: 'fade'
        });
    });
</script>

jQuery肯定已加载,我使用此链接来确保正确加载循环插件

<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>

!!!!!!!!!*已解决 * !!!!!!!!!

wordpress内部存在jQuery冲突。它有两个版本的jQuery同时运行

你只是使用了错误的选择器,如果你改变

$('.slideshow')

$('.slider')

它应该工作:http://jsfiddle.net/cchana/kenWK/

你指的是 Jquery 选择器中的错误选择器。

<script type="text/javascript">
    $(document).ready(function () {
        $('.slider').cycle({
            fx: 'fade'
        });
    });
</script>

这应该可以做到。

并且不要忘记关闭您以标签开始的第一个div。您的代码段不会显示它。

最新更新