views:

332

answers:

2

Hi,

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).ready(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 :)

+2  A: 

Uhh, maybe

$('div.post img').prettyPhoto();
Pointy
Thanks for the quick answer.. I tried that but I does not seem to work.. I'm using WordPress btw and prettyphoto works fine the "normal" way.
Bowe Frankema
Well what do you mean when you say that it "does not seem to work"? What happens? Are there errors in your Firebug console? Does anything happen at all?
Pointy
by Wordpress, you mean Wordpress.org, right?
Maxim Zaslavsky
Hi guys, I think I see where the problem lies, and why your suggestions are not working.. the image is linked to the full version so the div selector should be different.. I should open the linked full size image when clicked on the resized image in the content div!$("a[rel^='prettyPhoto']").prettyPhoto();Should be something like:$("a[divl^='div.post img a']").prettyPhoto();I think? thanks for the help!
Bowe Frankema
at Maxim: yes I mean WordPress but the selfhosted version of it :)
Bowe Frankema
You selector syntax sure does look strange to me. What is that supposed to mean? Stuff in square brackets is supposed to refer to element attribute values.
Pointy
A: 

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".

Maxim Zaslavsky
Oh, didn't see Pointy's answer when I started answering...
Maxim Zaslavsky
Hi guys, I think I see where the problem lies, and why your suggestions are not working.. the image is linked to the full version so the div selector should be different.. I should open the linked full size image when clicked on the resized image in the content div!$("a[rel^='prettyPhoto']").prettyPhoto();Should be something like:$("a[divl^='div.post img a']").prettyPhoto();I think? thanks for the help!
Bowe Frankema