【问题标题】:prettyphoto is not working with links not loaded with the DOMprettyphoto 不适用于未使用 DOM 加载的链接
【发布时间】:2013-06-28 20:33:22
【问题描述】:

我有一些图像,当点击其中任何一个时,会出现中等大小的图像,当点击中等大小时,它应该使用漂亮的照片加载大尺寸,但在点击任何小照片后加载中等大小的图像然后单击 ,edium 图像,漂亮的照片不起作用,更大的图像作为链接打开

$(document).ready(function(e) { 

$(document).on("click",".image a",function(){
    var num = $(this).parent().index()+1;
    $(".bottom").slideUp(500,',function(){
        $(".bottom").html("<a rel='prettyPhoto' href='images/"+num+"_large.jpg'><img src='images/"+num+"_med.jpg'></a>").slideDown(500);    
    });
});

$("a[rel='prettyPhoto']").prettyPhoto();
});

html

<div class="container">

<div class="top">
<div class="image"><img src="images/1.jpg"  alt=""/></div>
<div class="image"><img src="images/2.jpg"  alt=""/></div>
<div class="image"><img src="images/3.jpg"  alt=""/></div>
</div>

<div class="bottom">
<a href="images/1_large.jpg" rel="prettyPhoto"><img src="images/1_med.jpg" width="640" height="480"  alt=""/></a>
</div>

</div>

完整代码下载http://www.mediafire.com/?xd97aonsjz3oyc0

http://jsfiddle.net/frTAY/3/

【问题讨论】:

    标签: jquery prettyphoto


    【解决方案1】:

    您有语法错误。这是要使用的正确代码:

    $(document).on("click",".image a",function(){
        var num = $(this).parent().index()+1;
        $(".bottom").slideUp(500,function(){
            $(".bottom").html("<a rel='prettyPhoto' href='images/"+num+"_large.jpg'><img src=images/"+num+"_med.jpg></a>").slideDown(500);  
        });
    });
    

    【讨论】:

      猜你喜欢
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      相关资源
      最近更新 更多