Hi Guys,
I’ve been messing around with some basic jquery stuff and I’ve ran into a problem, one that I think is probably very easy to explain and get around.
I’ve made a vertical css menu from a list, and 1 of those list items has a ul as it’s list item, with several items within it.
When the parent li is hovered over I’ve set it so that the child ul and it’s li’s to drop down below it.
I want to use jquery to adjust this child ul so that display is set to none, but I can’t seem to work it out (Other than just giving the ul it’s own class or ID, but I’d rather learn how to do it another way).
Here’s the jquery I’ve got that theoretically should work (but doesn’t):
I think the problem lie in the li:hover part of the jquery, I’m guessing that it’s not allowed, or simply doesn’t work that way.
Can someone suggest the correct way for me.
I want jquery to set the display of that sub ul to none, then set a click or hover effect on it so it slides down in a fancy way (I’m pretty sure I can figure that part out on my own though.)
The only thing I want to learn how to do is to hide something with jquery (By setting it’s display property to none), if it’s already set to display on hover over in the css.
Basically, lets just use a standard ul, and the li’s have a hover property in the css to set the background color to blue, how can I disable that in jquery.
I can’t seem to use “ul > li:hover”
So how can I access and manipulate “li:hover”
Will I have to create a hover function such as:
$(‘ul > li’).hover(function(){
($this).css(‘property’,‘value’); //To set it to nothing
($this).css(‘background-color’,‘black’); //To set it to the new hover effect
});
I’m not really sure how I can explain this easily.
1 more attempt
The sub ul is a dropdown when it’s hovered over. I want to disable it by hiding it, then use jquery to make it slide down in a fancy way, rather than just appearing.
If you hover over the left menu item “Gallery” a new menu will come down. That’s the sub menu that is default to none, but set to display as block on hover.
I want to disable that effect with jquery. By default the li > ul is set to display none, but when that that li (That’s the parent of a ul) is hovered over, it changes the display of that sub ul to display block with
li:hover > ul {
display:block;
}
So I want to manupulate the “li:hover > ul” selector.
Does that make more sense, I’m still not sure if I’m explaining it as well as I can.
I know I could simply have the list display as none and JUST use jquery to make the fancy sliding effect, but I want my code to degrade gracefully.