i have a part of css code, how can i add this css with jquery ?
div#menu li:hover>div {
visibility: visible;
}
i have a part of css code, how can i add this css with jquery ?
div#menu li:hover>div {
visibility: visible;
}
If I'm not mistaken, the following should work with the newest version of jquery:
$("div#menu li:hover>div").css("visibility","visible")
Although Sarfraz and Anthony's answers would work there are a couple of points to note.
1) To hide/show you are better just using the hide()
and show()
mothods available on a jQuery object.
So,
$("div#menu li:hover>div").show();
2) Try to use css classes instead, rather than direct use of the .css()
function
3) With your selector, div#menu
is pointless. An id selector is faster. All you do when you put the element selector div
in front of it is slow it down:
$("#menu li:hover>div").show();
Also, start accepting answers and voting. It good courtesy - It earns people points, which they like, and makes them more inclined to help you in future.
Please check this link http://remysharp.com/2008/10/17/jquery-really-visible/
The Problem with :visible
The :visible selector works fine if you're asking whether the particular element has been set to invisible (either via the display or visibility CSS style).
However, if the element is hidden because a parent element is set to hidden, the :visible selector returns a false positive.