0

this seems to be a common problem which I have no idea how to solve.

So, I have a bunch of <div>'s whose id I decided for some reason to store in an array defined like

buttons = ["news", "info", "prog", "evnt"];

So one of the ways I use to get to slide them down is the following:

for (var i in buttons) $("#" + buttons[i]).slideDown ();

I also use this in the code:

for (var i in buttons)
   $("#" + buttons[i]).css ({display: "block"});

Neither, if the buttons are not visible, works (on IE 7 and 8), I get the usual "Object doesn't support this property or method" AFTER those blocks. Any ideas?

I also get a weird "unrecognized expression" error about jQuery, which confuses me.

marco
  • 806
  • 1
  • 7
  • 17

1 Answers1

0

several little things:

  • 1 - you can always append on the selector

    $("#news, #info, #prog, #evnt").slideDown();

  • 2 - always use a sequential for loop

    for (var i = 0; i < buttons.length; i++) { // do something }

  • 3 - when hiding, if you're using jQuery, why not hide?

    for (var i = 0; i < buttons.length; i++) { $("#" + buttons[i]).hide(); }

balexandre
  • 73,608
  • 45
  • 233
  • 342