简体   繁体   中英

how do i select a element within a div using jquery

i have a slideshow that is using the cycle plugin and for some reason i cant select or target the correct elements see the code below:

HTML

<div id="slider">

    <div id="slideshow">
        <ul>                    
        <li><img src="images/slider-one.png" height="380" width="960" alt="AquaPure Traveller" /></li>
        <li><img src="images/slider-one.png" height="380" width="960" alt="AquaPure Traveller" /></li>
        <li><img src="images/slider-one.png" height="380" width="960" alt="AquaPure Traveller" /></li>
        <li><img src="images/slider-one.png" height="380" width="960" alt="AquaPure Traveller" /></li>
        <li><img src="images/slider-one.png" height="380" width="960" alt="AquaPure Traveller" /></li>
        </ul>
    </div> <!-- End Slideshow -->

    <div id="prev">PREVIOUS</div>
    <div id="next">NEXT</div>

</div> <!-- End Slider -->

and the javascript

$(document).ready(function() { // Document Ready
            $('#slideshow ul li').cycle({
        'fx': 'scrollHorz', 
        'timeout': 8000,
        'prev': '#prev',
        'next': '#next',
        'pause': true
    });

}); // End Document Ready

what am i missing is it something simple or is it an issue with the plugin?

Thanks

You are using the jQuery Cycle Plugin right?

As far as I know you have to select the container / parent of the items. Try this:

$(document).ready(function() {         
   $('#slideshow ul').cycle({
        'fx': 'scrollHorz', 
        'timeout': 8000,
        'prev': '#prev',
        'next': '#next',
        'pause': true
    });
});

Change the JavaScript so that the cycle is applied to the ul element not the individual li:-

$('#slideshow ul').cycle();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM