您必须使用 Fotorama API、事件和方法(仍未记录):
<div class="thumbs">
<a href="1.jpg"><img src="1-thumb.jpg"></a>
<a href="2.jpg"><img src="2-thumb.jpg"></a>
</div>
<script>
$('.thumbs').each(function () {
$('a', this).each(function () {
var $a = $(this);
// set ids, will use them later
$a.attr({id: $a.attr('href').replace(/[\/\.-]/g, '')});
});
var $thumbs = $(this),
$fotorama = $thumbs.clone();
$fotorama
.on('fotorama:show', function (e, fotorama) {
// pick the active thumb by id
$('#' + fotorama.activeFrame.id)
.addClass('active')
.siblings()
.removeClass('active');
})
.addClass('fotorama')
.removeClass('thumbs')
.insertBefore(this)
.fotorama({nav: false, width: '100%', maxHeight: 400, ratio: 3/2});
// get access to the API
var fotorama = $fotorama.data('fotorama');
$thumbs.on('click', 'a', function (e) {
e.preventDefault();
// show frame by id
fotorama.show(this.id);
});
});
</script>
小提琴:http: //jsfiddle.net/artpolikarpov/tnWLv/embedded/result,html,css,js/