开发者

Javascript - Selecting the right image for input value

Ok, I have a simple javascript function in a bookmarklet that finds all of the images on a page and then shows them in the bookmarklet

for(var i=0; i<img_find.length; i++)
        {
            if (theImg[i].width > 200 && theImg[i].height > 200)
            {
                $("#image").append("<img id='photo' height='150' src='"+img_find[i]+"'/>");
                $("#width").append("<input type='hidden' value='"+img_find[i]+"' name='story_img'/>");
            }
        }

I also have a jquery slideshow so you can click next to scroll through the images.

Is there a way to get the current image the user is looking at on the slideshow to be the on that goes in my input value?

$('.slideshow').cycle({ 
        prev:   '#prev', 
        next:   '#next', 
        timeout: 0 
    });

<div id='image' class='slideshow' align='left'></div>
<a href='#' id='prev' style='font-size:10px;'>Previous</a>
<a href='#' i开发者_如何学运维d='next' style='font-size:10px;'>Next</a>

Thanks!


As per http://jquery.malsup.com/cycle/int2.html

You just have to add a before: function

$('.slideshow').cycle({ 
        prev:   '#prev', 
        next:   '#next', 
        before:  onBefore
        timeout: 0 
    });

function onBefore() { 
    $('#output').html("Scrolling image:<br>" + this.src); 
} 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜