[jQuery] Re: Adding incremental numbered classes to divs

2009-04-13 Thread Brain Lava

Thanks everyone!  You've definitely made some great points for me to
consider.  I'm really new to scripting (normally I can find plugins to
do what I want) and you're probably right that there is a much easier
solution to what I'm trying to achieve.

I'm going to take your suggestions and see what I can figure out on my
own.  If I can achieve the effect I'm desiring I'll post the end
result for some feedback.

Cheers!

On Apr 9, 5:54 pm, mkmanning  wrote:
> Since you're not using the class for styling, but indexing, why not
> just use the natural index of the div in its container, or from the
> jQuery object itself?
>
> $('.ngg-gallery-thumbnail-box') is an array-like object, so you can
> iterate over it, or access its members by index number, such as $
> ('.ngg-gallery-thumbnail-box').get(8).
>
> If you're building a carousel, adding incremental numbers to the
> classname to drive the carousel seems overkill.
>
> On Apr 9, 11:54 am, Brain Lava  wrote:
>
> > Normally I would agree with you but the effect I'm trying to achieve
> > is based on the location of the image in the grid and not tied to the
> > image itself.  I don't want the end user to have to update the CSS
> > every time they move an image or add a new one to their gallery.  This
> > seemed like the best way to achieve my end result.
>
> > On Apr 9, 9:37 am, brian  wrote:
>
> > > That seems like you're fighting against the convention. Why create a
> > > zillion classes when these same divs already have an incremented ID?
> > > (The ID being the proper place to do this sort of thin, in the 1st
> > > place)
>
> > > On Thu, Apr 9, 2009 at 1:31 AM, Brain Lava  wrote:
>
> > > > I'm really new to jQuery and have been struggling with a concept that
> > > > I would think is pretty simple but I can't seem to find anything
> > > > online that does what I need.
>
> > > > I'm using NextGen Gallery for Wordpress and I would like to assign an
> > > > incremental class to each div that the gallery outputs.  For example
> > > > the gallery gives me the following code:
>
> > > > 
> > > >   
> > > >   
> > > >   
> > > > 
>
> > > > What I would like to do is replace the append class of the interior
> > > > divs with a number that automatically increments by 1:
> > > > 
> > > >   
> > > >   
> > > >   
> > > > 
>
> > > > I've seen this done in carousel scripts but I can't seem to figure out
> > > > how they do it.
>
> > > > Any help would be greatly apprecaited.


[jQuery] Re: Adding incremental numbered classes to divs

2009-04-13 Thread Brain Lava

Thanks everyone!  You've definitely made some great points for me to
consider.  I'm really new to scripting (normally I can find plugins to
do what I want) and you're probably right that there is a much easier
solution to what I'm trying to achieve.

I'm going to take your suggestions and see what I can figure out on my
own.  If I can achieve the effect I'm desiring I'll post the end
result for some feedback.

Cheers!

On Apr 9, 5:54 pm, mkmanning  wrote:
> Since you're not using the class for styling, but indexing, why not
> just use the natural index of the div in its container, or from the
> jQuery object itself?
>
> $('.ngg-gallery-thumbnail-box') is an array-like object, so you can
> iterate over it, or access its members by index number, such as $
> ('.ngg-gallery-thumbnail-box').get(8).
>
> If you're building a carousel, adding incremental numbers to the
> classname to drive the carousel seems overkill.
>
> On Apr 9, 11:54 am, Brain Lava  wrote:
>
> > Normally I would agree with you but the effect I'm trying to achieve
> > is based on the location of the image in the grid and not tied to the
> > image itself.  I don't want the end user to have to update the CSS
> > every time they move an image or add a new one to their gallery.  This
> > seemed like the best way to achieve my end result.
>
> > On Apr 9, 9:37 am, brian  wrote:
>
> > > That seems like you're fighting against the convention. Why create a
> > > zillion classes when these same divs already have an incremented ID?
> > > (The ID being the proper place to do this sort of thin, in the 1st
> > > place)
>
> > > On Thu, Apr 9, 2009 at 1:31 AM, Brain Lava  wrote:
>
> > > > I'm really new to jQuery and have been struggling with a concept that
> > > > I would think is pretty simple but I can't seem to find anything
> > > > online that does what I need.
>
> > > > I'm using NextGen Gallery for Wordpress and I would like to assign an
> > > > incremental class to each div that the gallery outputs.  For example
> > > > the gallery gives me the following code:
>
> > > > 
> > > >   
> > > >   
> > > >   
> > > > 
>
> > > > What I would like to do is replace the append class of the interior
> > > > divs with a number that automatically increments by 1:
> > > > 
> > > >   
> > > >   
> > > >   
> > > > 
>
> > > > I've seen this done in carousel scripts but I can't seem to figure out
> > > > how they do it.
>
> > > > Any help would be greatly apprecaited.


[jQuery] Re: Adding incremental numbered classes to divs

2009-04-09 Thread Brain Lava

Thanks Ralph!  I'll give that a try :)

On Apr 9, 10:13 am, Ralph Whitbeck  wrote:
> You can use .each to iterate through each div element and increment the
> classname or ID via it's index.
>
> $("div").each(function(i) {
>     $(this).addClass("classname" + i);
>
> });
>
> http://docs.jquery.com/Core/each
>
> HTH
> Ralph
>
> On Thu, Apr 9, 2009 at 9:37 AM, brian  wrote:
>
> > That seems like you're fighting against the convention. Why create a
> > zillion classes when these same divs already have an incremented ID?
> > (The ID being the proper place to do this sort of thin, in the 1st
> > place)
>
> > On Thu, Apr 9, 2009 at 1:31 AM, Brain Lava  wrote:
>
> > > I'm really new to jQuery and have been struggling with a concept that
> > > I would think is pretty simple but I can't seem to find anything
> > > online that does what I need.
>
> > > I'm using NextGen Gallery for Wordpress and I would like to assign an
> > > incremental class to each div that the gallery outputs.  For example
> > > the gallery gives me the following code:
>
> > > 
> > >   
> > >   
> > >   
> > > 
>
> > > What I would like to do is replace the append class of the interior
> > > divs with a number that automatically increments by 1:
> > > 
> > >   
> > >   
> > >   
> > > 
>
> > > I've seen this done in carousel scripts but I can't seem to figure out
> > > how they do it.
>
> > > Any help would be greatly apprecaited.


[jQuery] Re: Adding incremental numbered classes to divs

2009-04-09 Thread Brain Lava

Normally I would agree with you but the effect I'm trying to achieve
is based on the location of the image in the grid and not tied to the
image itself.  I don't want the end user to have to update the CSS
every time they move an image or add a new one to their gallery.  This
seemed like the best way to achieve my end result.

On Apr 9, 9:37 am, brian  wrote:
> That seems like you're fighting against the convention. Why create a
> zillion classes when these same divs already have an incremented ID?
> (The ID being the proper place to do this sort of thin, in the 1st
> place)
>
> On Thu, Apr 9, 2009 at 1:31 AM, Brain Lava  wrote:
>
> > I'm really new to jQuery and have been struggling with a concept that
> > I would think is pretty simple but I can't seem to find anything
> > online that does what I need.
>
> > I'm using NextGen Gallery for Wordpress and I would like to assign an
> > incremental class to each div that the gallery outputs.  For example
> > the gallery gives me the following code:
>
> > 
> >   
> >   
> >   
> > 
>
> > What I would like to do is replace the append class of the interior
> > divs with a number that automatically increments by 1:
> > 
> >   
> >   
> >   
> > 
>
> > I've seen this done in carousel scripts but I can't seem to figure out
> > how they do it.
>
> > Any help would be greatly apprecaited.


[jQuery] Adding incremental numbered classes to divs

2009-04-09 Thread Brain Lava

I'm really new to jQuery and have been struggling with a concept that
I would think is pretty simple but I can't seem to find anything
online that does what I need.

I'm using NextGen Gallery for Wordpress and I would like to assign an
incremental class to each div that the gallery outputs.  For example
the gallery gives me the following code:


   
   
   


What I would like to do is replace the append class of the interior
divs with a number that automatically increments by 1:

   
   
   


I've seen this done in carousel scripts but I can't seem to figure out
how they do it.

Any help would be greatly apprecaited.