views:

48

answers:

1

I have some DIVs that I am using JQuery to hide and show using the toggle() function. This has been working fine.

But I just recognized some relationships between some of these DIVs that would allow me to group some of them into a class.

I was hoping that this would allow me to toggle the DIV class instead of each of the DIV ids.

So I want to do this:

$("#myDIVId1").click(function ()
{
  $("myDIVClass").hide();
  $("#myToggle1").toggle();
});

Instead of this:

$("#myDIVId1").click(function ()
{
  $("#myToggle2").hide();
  $("#myToggle3").hide();
  $("#myToggle4").hide();
  $("#myToggle5").hide();
  $("#myToggle1").toggle();
});

But only this verbose ID access seems to work. Any ideas why?

+2  A: 

When you select the class, you need to put a '.'

$(".myDIVClass").hide();
Geoff