开发者

Using jcarousel, how can I get the image alt to display in an external div#caption

开发者 https://www.devze.com 2023-03-29 00:38 出处:网络
I am using: http://sorgalla.com/projects/jcarousel/#Configuration And I am implementing this locally to prove functionality before I load it into a site.My current setup is:

I am using: http://sorgalla.com/projects/jcarousel/#Configuration

And I am implementing this locally to prove functionality before I load it into a site. My current setup is:

<script type="text/javascript">
function mycarousel_initCallback(carousel) {

jQuery('#mycarousel-next').bind('click', function() {
    carousel.next();
    return false;
});

jQuery('#mycarousel-prev').bind('click', function() {
    carousel.prev();
    return false;
});
};

jQuery(document).ready(function() {
jQuery("#mycarousel").jcarousel({
    scroll: 1,
    visible: 1.1,   
    initCallback: mycarousel_initCallback,
    buttonNextHTML: null,
    buttonPrevHTML: null,
    itemLoadCallback: trigger
});
});
function trigger(carousel, state)
{
$("#counter").html(carousel.first);  
}
</script>
<div id="clip">

<ul id="mycarousel">
    <li><img src="images/bda_1.jpg" alt="Alt Tag 1" width="638" height="358"/></li>
    <li><img src="images/bda_2.jpg" alt="Alt Tag 2" width="638" height="358" /></li>
    <li><img src="images/bda_3.jpg" alt="Alt Tag 3" width="638" height="358" /></li>
    <li><img src="images/bda_1.jpg" width="638" height="358" /></li>
</ul>

开发者_JS百科</div>
 <a href="#" id="mycarousel-prev">&laquo; Prev</a>
 <a href="#" id="mycarousel-next">&laquo; NEXT</a>

<div id="counter"></div>

<div id="caption"></div>

I know I can use a callback but my js/jquery is to beginner to get it done. I simply want to pull the alt tag out and display it in the div#caption

thanks for the help.


In the jcarousel main loop (which I don't see in your code) you'd so this:

$('#caption').html($('mycarousel').find('img').eq(COUNTER).attr('alt'))

Where the value of COUNTER comes fom you'll have to find in the script. If there's a callback for this function you could put it there.

0

精彩评论

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