开发者

dual click problem

开发者 https://www.devze.com 2023-01-05 05:18 出处:网络
i\'ve made an image slide show which works with either a next button, or if you click on the right or left of the screen it shows the next slide.

i've made an image slide show which works with either a next button, or if you click on the right or left of the screen it shows the next slide.

problem is when i click the next button the click bind also fires which means it move forward 2 slides.

How can i get the click bind to ignore the click if th next button is clicked?!

    $(opts.next).click(function(){

        nextSlide();

    });

    function nextSlide() {
        $slides.eq(currentSlide).fadeOut(opts.speed)

        currentSlide++;

        (currentSlide==totalSlides ? currentSlide=0 : false);

        updateSlideSHow()

    }

    function previousSlide() {
        $slides.eq(currentSlide).fadeOut(opts.speed)

        currentSlide--;

        (currentSlide<0 ? currentSlide=(totalSlides-1) : false);

        updateSlideSHow()

    }

    $(this).bind('mouseup',function(e){
        var ww = $(window).width();

        (e.pageX < (ww/2) ? previousSlide开发者_运维知识库() : nextSlide());
            //alert(e.pageX+"<"+ww);

    });

any help appreciated!


Where are the "next" buttons according to the DOM? Is the screen element, where I can click and go to the next slide, the parent element of these buttons?

The reason I ask is if they are that way, for instance:

<div id='screen'>
<img id='nextBtn' />
</div>

I'm not 100% but I would think if you tried clicking on the image button that the div would also register as a click, since its the parent element. Instead you could try this:

<div id='screen'></div>
<img id='nextBtn' />

And position the screen element absolutely and behind the image element.


ok - basically got the click to check for a URL before executing;

            $(document).bind('click',function(e){
                var ww = $(window).width();

                if(!$(this).attr('href')) $()(e.pageX < (ww/2) ? previousSlide() : nextSlide());
                //alert(e.pageX+"<"+ww);

            });


Just curious, but if clicking the button would go to next through the click event, why not leave a button that does nothing there?

0

精彩评论

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