views:

54

answers:

2

Trying to make a simple toggle menu, and I can't seem to hide/show the sub menu using this bit of jQuery:

$(".topic news").mouseup(function(){
    $(".feed groups").hide("fast", function(){
      $(".feed messages").hide("fast");
      $("ul.feed news").toggle("fast");
    });
  });

Here is the corresponding HTML:

<div class="topic news">
  <span>News Feed</span>
 </div>
 <ul class="feed news">
  <li>News item #1</li>
  <li>News item #1</li>
  <li>News item #1</li>
  <li>News item #1</li>
  <li>News item #1</li>
 </ul>

Any ideas?

+5  A: 

To select a div with multiple classes, whether in CSS or jQuery, you concatenate multiple class selectors:

// Notice the dot instead of the space in all these selectors
$(".topic.news").mouseup(function(){
    $(".feed.groups").hide("fast", function(){
      $(".feed.messages").hide("fast");
      $("ul.feed.news").toggle("fast");
    });
});
BoltClock
Perfect, thanks man
Cortopasta
A: 

No effects will get fired as there is no html that has classes feed and groups

$(".feed.groups").hide("fast", function(){

unless you've omitted that.

dalton