有人知道如何使用 Jquery PrettyPhoto 通过 ChangePictureCallback 函数检索当前图像数据(alt、src)吗?
我想将这两个变量传递给 ajax 脚本,但似乎无法获取要传递的信息。试过了,没有效果。
var image = jQuery(".pp_pic_holder").find("#pp_full_res img").attr("src");
必须有一种方法可以在运行时轻松访问这些数据。 有什么建议或指出正确的方向吗?
当我与 Gallerific 合作时,我能够使用
获取此信息var image_src = this.data[nextIndex].slideUrl;
编辑=>只需缩小目标搜索范围
var image = jQuery('#fullResImage').attr('src');
现在工作得很好。
最佳答案
从技术上讲,您的尝试是正确的,但尝试扩大您的范围,并进行一些测试......
myCallbackTest = function() {
alert('the callback worked! thats a good start!');
var $activeimage = $("#fullResImage");
var source = $activeimage.attr('src'), altText = $activeimage.attr('alt');
if(!$activeimage.length) {
alert('The image selector failed');
} else if (!source) {
alert('The image selector worked, but I found no source');
} else if (!altText) {
alert('Found The image and its source, but it doesnt seem to have any alt text');
} else {
alert('i got it! alt: ' + altText + ' src: ' + source);
}
}
那就试试吧...
$(function() {
$('a[rel^=prettyPhoto]').prettyPhoto({
theme: 'facebook',
slideshow:5000,
autoplay_slideshow:true,
changepicturecallback: myCallbackTest
});
});
关于jquery - 漂亮照片更改图片回调数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9881083/