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

I have a lightbox script installed, and now I want to apply a script for each image in the content div. How can I achieve this?

My current JS code is:

       <script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
   $("a[rel^='prettyPhoto']").prettyPhoto();
  });
 </script>

css / div I want to apply to:

div.post img {

I somehow can't get this to work, and my jQuery skills don't exist :)

Thanks in advance for any help :)

+3
source share
2 answers

Currently you find all tags <a>with rel='prettyPhoto'and use the prettyPhoto () plugin.

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

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

, , JQuery, div css, . , prettyPhoto() "div.post img".

+2

Uhh,

$('div.post img').prettyPhoto();
+2

Source: https://habr.com/ru/post/1732764/


All Articles