ahlexander
ahlexander

Reputation: 341

jQuery click does not work but toggle does

This is doing nothing:

$("#nav li ul li").click(function(){
  $(this).find('ul:first').css({
    visibility: "visible"
  });
});

This is working (showing and hiding):

$("#nav li ul li").toggle(function() {
  $(this).find('ul:first').css({
    visibility: "visible"
  });
}, function() {
  $(this).find('ul').css({
    visibility: "hidden"
  });
});

I want to get the first one to work, I don't want it to toggle.

Upvotes: 1

Views: 125

Answers (2)

DevlshOne
DevlshOne

Reputation: 8457

CSS

.ghost{visibility:hidden;}

jQuery

$("#nav li ul li").click(function() {
    $(this).find('ul:first').toggleClass('ghost')
});

Upvotes: 0

Code Lღver
Code Lღver

Reputation: 15593

Try this code:

$("#nav li ul li").click(function(){
  $(this).find('ul').first().css("visibility","visible");
});

Upvotes: 1

Related Questions