开发者

How can I apply a lightbox (prettyphoto) to all images in the content div?

开发者 https://www.devze.com 2022-12-20 16:13 出处:网络
I have a lightbox script installed and now I want to apply the script on every image within the content div. How can I achieve this?

I have a lightbox script installed and now I want to apply the script on every image within the content div. How can I achieve this?

My current JS code:

       <script type="text/javascript" charset="utf-8">
  $(document).read开发者_如何学运维y(function(){
   $("a[rel^='prettyPhoto']").prettyPhoto();
  });
 </script>

The css/div I want it applied to:

div.post img {

I somehow can't get this to work, and my jQuery skills are non existent :)

Thanks in advance for any help :)


Currently, you're finding all <a> tags with rel='prettyPhoto' and using the prettyPhoto() plugin on them.

You can apply the same methodology to your div.post img {selector, by doing something like:

$("div.post img").prettyPhoto();

All I did was change the JQuery selector to match the div css identifier you provided. So, prettyPhoto() will be applied to all elements in "div.post img".


Uhh, maybe

$('div.post img').prettyPhoto();
0

精彩评论

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