最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript or jQuery image carousel with dynamically loaded images and links - Stack Overflow

programmeradmin5浏览0评论

Is there a good javascript or jQuery image carousel that will display 5 images and if there are more, the user can click next and the following image sources and link URLs will load through AJAX?

It's very possible there are thousands of images and each links to a webpage devoted to that image, so I basically need an image carousel that can efficiently deal with this.

Is there a good javascript or jQuery image carousel that will display 5 images and if there are more, the user can click next and the following image sources and link URLs will load through AJAX?

It's very possible there are thousands of images and each links to a webpage devoted to that image, so I basically need an image carousel that can efficiently deal with this.

Share Improve this question asked Oct 13, 2011 at 18:15 at.at. 52.6k105 gold badges303 silver badges470 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 6 +25

I think the JQuery Cycle Plugin will get you 50% of the way there. This facility is pretty easy to use and I think will give you the "click to get to more" images functionality that you're after (with some pretty nifty transition effects at that).

However, I've only used the plugin with all the images defined in the page. In my case, I was doing a "slide show" to demonstrate the use of an application. The HTML was pretty simple...

<div id="slideshow">
  <img src="Images/Usage1.png" />
  <img src="Images/Usage2.png" />
  <img src="Images/Usage3.png" />
  <img src="Images/Usage4.png" />
  <img src="Images/Usage5.png" />
  <img src="Images/Usage6.png" />
  <img src="Images/Usage7.png" />
  <img src="Images/Usage8.png" />
  <img src="Images/Usage9.png" />
  <img src="Images/Usage10.png" />
</div>
<a href="javascript:moveSlide('prev');" style="float: left;">&lt; Prev</a>
<a href="javascript:moveSlide('next');" style="float: right;">Next &gt;</a>

The associated JavaScript is...

function moveSlide(direction) {
    $("#slideshow").cycle(direction);
} // End function

$(document).ready(function () {
    $("#slideshow").cycle({
        fx: 'fade',
        speed: 300,
        timeout: 0
    });
});

(Click here to see the effect.)

As for addressing the additional challenge of loading new images when the user wants to fetch some more, I think that's just a matter of expanding on the code behind the "Next" link in my example. Your code would perform a JQuery AJAX call to get the next images and then add them to the slideshow div.

Lastly, that leaves the functionality of clicking on the image to go to the site. You can try putting the slideshow img tags inside of appropriate a tags. If the cycle plugin doesn't play will with the a tags, onclick event handlers on the images should get the job done.

You could use jQuery Tools' Scrollable as slider and associate a $get() call to the 'next' button.

Here's a demo: http://flowplayer/tools/demos/scrollable/edit.htm (Notice the 'add' button).

In this demo, it just clones a div and append it. You could do the same when clicking on 'next' but loading content from elsewhere.

I've used jShowOff for a project.

Benefits:

  • You have plete control over each slide's HTML, (so, image or images, HTML, and links can be used
  • Per one of your requirements, the user is able to rotate the slides on their own

Problem

  • You'd have to e up with your own AJAX solution and tweak it.

http://ekallevig./jshowoff/

I have an example of my use of it here: http://www.rhmachine./ (the links can be modified to only show prev/next).

I'll dig around for a bit and see if I can find an AJAX solution already made for it.

The first solution is pretty good, another solution that you might like and that I use : http://jquery.malsup./cycle/

发布评论

评论列表(0)

  1. 暂无评论