0

这是我的代码:

<div class='silderitem'>
Some Content
</div>

<div class='silderitem'>
Another Some Content
</div>

<div class='silderitem'>
Again Another Some Content
</div>

<a class="next">next</a>

当我使用 jquery 单击“下一步”时,我想更改下一个课程。我试过这个,但它不起作用。

<script>
$(document).ready(function(){
    var Slideshow=$('.slideritem');
    $(".next").click(function(){slideshow.next();return false});
</script>

谁能告诉我解决方案吗?

4

1 回答 1

1

如果您想循环浏览项目,隐藏未选择的项目,这样的事情可能会起作用:jsfiddle

CSS:

.silderitem { display: none }
.next { cursor: pointer }​

jQuery:

$('.selected').show();

$(".next").click(function(){
    var selected = $('.selected');
    selected.removeClass('selected');
    selected.hide();

    var next = selected.next(".silderitem");
    if(next.length === 0) {
        next = $(".silderitem").first();
    }
    next.addClass('selected');
    next.show();
});​

html:

<div class='silderitem selected'>
Some Content
</div>

<div class='silderitem'>
Another Some Content
</div>

<div class='silderitem'>
Again Another Some Content
</div>

<a class="next">next</a>
于 2012-08-22T13:52:43.520 回答