开发者

alter prettyphoto to pull from div or span, not title

开发者 https://www.devze.com 2023-01-03 02:58 出处:网络
Here\'s the section of code from prettyphoto.js that I need to alter. What I am trying to achieve is have each photo have a following hidden div or span that holds the description for the photo. This

Here's the section of code from prettyphoto.js that I need to alter. What I am trying to achieve is have each photo have a following hidden div or span that holds the description for the photo. This way I can include html in the description.

Possible?

Thanks!

var images = new Array(), titles = new Array(), descriptions = new Array();
if(theGallery){
 $('a[rel*='+theGallery+']').each(function(i){
  if($(this)[0开发者_Go百科] === $(_self)[0]) setPosition = i; // Get the position in the set
  images.push($(this).attr('href'));
  titles.push($(this).find('img').attr('alt'));
  descriptions.push($(this).attr('title'));
 });
}else{
 images = $(this).attr('href');
 titles = ($(this).find('img').attr('alt')) ?  $(this).find('img').attr('alt') : '';
 descriptions = ($(this).attr('title')) ?  $(this).attr('title') : '';
}

$.prettyPhoto.open(images,titles,descriptions);
return false;

});


This should work (untested) as long as the span comes right after the image.

var images = new Array(), titles = new Array(), descriptions = new Array();
if(theGallery){
 $('a[rel*='+theGallery+']').each(function(i){
  if($(this)[0] === $(_self)[0]) setPosition = i; // Get the position in the set
  images.push($(this).attr('href'));
  titles.push($(this).find('img').attr('alt'));
  descriptions.push($(jQuery.sibling(this).next).text());
 });
}else{
 images = $(this).attr('href');
 titles = ($(this).find('img').attr('alt')) ?  $(this).find('img').attr('alt') : '';
 descriptions = ($(jQuery.sibling(this).next).text()) ?  $(jQuery.sibling(this).next).text() : '';
}

$.prettyPhoto.open(images,titles,descriptions);
return false;
}));
0

精彩评论

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