jQuery: The Write Less, Do More JavaScript Library

how i can access classes in my div?

View: New views
8 Messages — Rating Filter:   Alert me  

how i can access classes in my div?

by luciano mazzetto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


how i can access classes in my div?
example:

$("#box1.bloc-top").click(function () {
          $(".bloc-center").slideToggle("slow");
});

$("#box2.bloc-top").click(function () {
          $(".bloc-center").slideToggle("slow");
});

$("#box3.bloc-top").click(function () {
          $(".bloc-center").slideToggle("slow");
});


<div id="box1" class="box">
     <bloc-top>content top</bloc-top>
     <bloc-center>content slideToggle</bloc-center>
</div>

<div id="box2" class="box">
     <bloc-top>content top</bloc-top>
     <bloc-center>content slideToggle</bloc-center>
</div>

etc..
i tryed this it but no success

Re: how i can access classes in my div?

by luciano mazzetto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hdfsuahd it`s ok ok..
i forgot space.."#box2. bloc-top"

On 12 maio, 20:35, Luciano <lmazze...@...> wrote:

> how i can access classes in my div?
> example:
>
> $("#box1.bloc-top").click(function () {
>           $(".bloc-center").slideToggle("slow");
>
> });
>
> $("#box2.bloc-top").click(function () {
>           $(".bloc-center").slideToggle("slow");
>
> });
>
> $("#box3.bloc-top").click(function () {
>           $(".bloc-center").slideToggle("slow");
>
> });
>
> <div id="box1" class="box">
>      <bloc-top>content top</bloc-top>
>      <bloc-center>content slideToggle</bloc-center>
> </div>
>
> <div id="box2" class="box">
>      <bloc-top>content top</bloc-top>
>      <bloc-center>content slideToggle</bloc-center>
> </div>
>
> etc..
> i tryed this it but no success

Re: how i can access classes in my div?

by darren-49 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


you could even use commas in your selector so that you aren't
repeating your statements.

On May 12, 5:51 pm, Luciano <lmazze...@...> wrote:

> hdfsuahd it`s ok ok..
> i forgot space.."#box2. bloc-top"
>
> On 12 maio, 20:35, Luciano <lmazze...@...> wrote:
>
> > how i can access classes in my div?
> > example:
>
> > $("#box1.bloc-top").click(function () {
> >           $(".bloc-center").slideToggle("slow");
>
> > });
>
> > $("#box2.bloc-top").click(function () {
> >           $(".bloc-center").slideToggle("slow");
>
> > });
>
> > $("#box3.bloc-top").click(function () {
> >           $(".bloc-center").slideToggle("slow");
>
> > });
>
> > <div id="box1" class="box">
> >      <bloc-top>content top</bloc-top>
> >      <bloc-center>content slideToggle</bloc-center>
> > </div>
>
> > <div id="box2" class="box">
> >      <bloc-top>content top</bloc-top>
> >      <bloc-center>content slideToggle</bloc-center>
> > </div>
>
> > etc..
> > i tryed this it but no success

Re: how i can access classes in my div?

by luciano mazzetto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


how i could do it`s commands?

On 12 maio, 22:35, darren <minof...@...> wrote:

> you could even use commas in your selector so that you aren't
> repeating your statements.
>
> On May 12, 5:51 pm, Luciano <lmazze...@...> wrote:
>
> > hdfsuahd it`s ok ok..
> > i forgot space.."#box2. bloc-top"
>
> > On 12 maio, 20:35, Luciano <lmazze...@...> wrote:
>
> > > how i can access classes in my div?
> > > example:
>
> > > $("#box1.bloc-top").click(function () {
> > >           $(".bloc-center").slideToggle("slow");
>
> > > });
>
> > > $("#box2.bloc-top").click(function () {
> > >           $(".bloc-center").slideToggle("slow");
>
> > > });
>
> > > $("#box3.bloc-top").click(function () {
> > >           $(".bloc-center").slideToggle("slow");
>
> > > });
>
> > > <div id="box1" class="box">
> > >      <bloc-top>content top</bloc-top>
> > >      <bloc-center>content slideToggle</bloc-center>
> > > </div>
>
> > > <div id="box2" class="box">
> > >      <bloc-top>content top</bloc-top>
> > >      <bloc-center>content slideToggle</bloc-center>
> > > </div>
>
> > > etc..
> > > i tryed this it but no success

Re: how i can access classes in my div?

by Andrea Varnier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 13 Mag, 01:35, Luciano <lmazze...@...> wrote:

> how i can access classes in my div?
> <div id="box1" class="box">
>      <bloc-top>content top</bloc-top>
>      <bloc-center>content slideToggle</bloc-center>
> </div>
>
> <div id="box2" class="box">
>      <bloc-top>content top</bloc-top>
>      <bloc-center>content slideToggle</bloc-center>
> </div>

looking at your code, the action is something like this:
"when the user clicks on a bloc-top element, slide-toggle the next
bloc-center element"
right? this is done in jQuery like this (assuming bloc-top and bloc-
center are classes):

$('.bloc-top').click(function(){
    $(this).next('.bloc-center').slideToggle('slow');
});

:)

Re: how i can access classes in my div?

by Duane Johnson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I wonder if you're looking for 'filter' instead of 'next'?

$('.bloc-top').click(function(){
  $(this).filter('.bloc-center').slideToggle('slow');
});


> looking at your code, the action is something like this:
> "when the user clicks on a bloc-top element, slide-toggle the next
> bloc-center element"
> right? this is done in jQuery like this (assuming bloc-top and bloc-
> center are classes):
>
> $('.bloc-top').click(function(){
>     $(this).next('.bloc-center').slideToggle('slow');
>
> });
>
> :)

Re: how i can access classes in my div?

by Andrea Varnier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 13 Mag, 16:29, canadaduane <duane.john...@...> wrote:
> I wonder if you're looking for 'filter' instead of 'next'?
>
> $('.bloc-top').click(function(){
>   $(this).filter('.bloc-center').slideToggle('slow');
> });

well... first of all I'm not quite sure about the html Luciano posted.
I supposed something like this:

> <div id="box1" class="box">
>      <div class="bloc-top">content top</div>
>      <div class="bloc-center">content slideToggle</div>
> </div>

because the code he posted at the beginning contains the class
selector $('.bloc-center'), but there is no class="bloc-center" in the
sample html.

anyway, filter() will not work in this case, because bloc-center is
not inside bloc-top, but it's next to it.
so I'm using next()

but maybe I went too far.
correct jQuery for an xml like this:

<div id="box2" class="box">
     <bloc-top>content top</bloc-top>
     <bloc-center>content slideToggle</bloc-center>
</div>

would be:

$('bloc-top').click(function(){
    $(this).next().slideToggle('slow');
});

Re: how i can access classes in my div?

by luciano mazzetto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

all OK. thanks

On Wed, May 14, 2008 at 5:02 AM, andrea varnier <andrea.varnier@...> wrote:

On 13 Mag, 16:29, canadaduane <duane.john...@...> wrote:
> I wonder if you're looking for 'filter' instead of 'next'?
>
> $('.bloc-top').click(function(){
>   $(this).filter('.bloc-center').slideToggle('slow');
> });

well... first of all I'm not quite sure about the html Luciano posted.
I supposed something like this:

> <div id="box1" class="box">
>      <div class="bloc-top">content top</div>
>      <div class="bloc-center">content slideToggle</div>
> </div>

because the code he posted at the beginning contains the class
selector $('.bloc-center'), but there is no class="bloc-center" in the
sample html.

anyway, filter() will not work in this case, because bloc-center is
not inside bloc-top, but it's next to it.
so I'm using next()

but maybe I went too far.
correct jQuery for an xml like this:

<div id="box2" class="box">
    <bloc-top>content top</bloc-top>
    <bloc-center>content slideToggle</bloc-center>
</div>

would be:

$('bloc-top').click(function(){
   $(this).next().slideToggle('slow');
});



--
att.
Luciano M.
www.m2t.com.br