Artur Rain
Artur Rain

Reputation: 359

Select children with jquery

I'm struggling to find an option to select the img of the div.

In my markup I only have this:

      <div class="slideshow-container">
                <div id="loading" class="loader"></div>
                <div id="slideshow" class="slideshow"></div>
            </div>

When it is rendered in browser it is like this: Inspect source

This is the gallery I use: Galleriffic

I want to select the images of the #slideshow and add class to it. Please help.

UPDATE: In the gallery js file I have found where the image is added, but I cant get it to add a class.

Here's what I'm trying: enter image description here

Upvotes: 0

Views: 89

Answers (5)

naor
naor

Reputation: 3650

I accomplished this by modifying the refresh function of galleriffic:

refresh: function() {
   // skip to this line of code:
   if (!imageData.image) {
      var image = new Image();

      // Add this line
      image.className = your_class_name_here

Upvotes: 1

Dan
Dan

Reputation: 184

$('#slideshow').find('img').addClass('classname')

Upvotes: 0

Eli
Eli

Reputation: 14827

Try this:

 $("#slideshow").find('.advance-link').children('img').addClass('newClass');

Upvotes: 0

palaѕн
palaѕн

Reputation: 73896

Try this:

$('#slideshow').find('img').addClass('someclass');

Upvotes: 2

PSL
PSL

Reputation: 123739

Try this:- You may need to look at the jquery selectors.

 $('#slideshow img').addClass('newclass');

If you want to specifically look at the images inside your hyperlink and done want to affect any other images if present in the #slideshow directly you should use this.:-

 $("#slideshow > .advance-link > img").addClass('newClass');

Upvotes: 2

Related Questions