Or simply use the inner text, but that will cause issues if you have
spaces in it.

$('button').click(function () {
      var data = $(this).text().toLowerCase();
      $('p.'+data).toggle('slow');
});


On Jan 27, 3:29 pm, Mike Alsup <mal...@gmail.com> wrote:
> > Is it possible to add :
> >   <script>
> >   $(document).ready(function(){
>
> >     $("button").click(function () {
> >       $("p").toggle("slow");
> >     });
>
> >   });
> >   </script>
>
> > that works for sevoral items, example, this is my menu :
>
> > <button class="button" style="background:transparent #33CC00">News</
> > button>
> > <br>
> > <button class="contact" style="background:transparent
> > #33CC00">Contact</button>
> > <br>
> > <button class="staff" style="background:transparent #33CC00"> Staff </
> > button>
> > <br>
> > <button class="join" style="background:transparent #33CC00">Join</
> > button>
> > <br><button class="forum" style="background:transparent
> > #33CC00">Forum</button>
> > <br><button class="status" style="background:transparent
> > #33CC00">Status</button>
> > </div>
>
> > i want each button to open a different paragraph, please tell me how i
> > do this ( aka <button>news</button> opens <p class=news> text </p> ,
> > etc. :D )
>
> An approach like this should work:
>
> <script>
> $(document).ready(function(){
>         $('button').click(function () {
>                 var data = $(this).attr('data');
>                 $('p.'+data).toggle('slow');
>         });});
>
> </script>
>
> <button class="button" data="news">News</button>
> <button class="button" data="staff">Staff</button>
>
> <p class="news"></p>
> <p class="staff"></p>

Reply via email to