开发者

creating IF ELSE statements

I am looking to create an IF ELSE statement that says IF You reach the end of the UL LI, unbind click function from scroll button, ELSE bind click function

$(document).ready(function () {

    $('#down').click(function () {
        $(".project_thumbs").stop().animate({
            "top": "-=510px"
        });
    });
 开发者_如何学编程   $('#up').click(function () {
        $(".project_thumbs").stop().animate({
            "top": "+=510px"
        });


    });
});


As you are using positional movements, all you need to do is multiply the number of LI's by the height of the LI's, and then when the LI's CSS top position is that figure (negative or positive?) then you are at the final scroll.

I have done this here on the horizontal axis

function run_slider() {
var elm = $('#slider ul li');
ct = elm.length-1;
ct = ct*-920; // 920 = width of li's, but could easily be found using jQuery
var x = $(elm).css('left');
x = parseInt(x);
if (x == ct) {
$(elm).animate({
  left: '0px'
 },500);
}
else {
$(elm).animate({
  left: '-=920px'
 },500);
}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜