This looks valid but it's not working. I'd like the 'huh' div to become opaque when the menu is hovered over. I tried this with fadein/out and it worked but just the once which was odd.
<script type="text/javascript">
$( function() {
$('#menuNav').hover( function() {
$('#huh').addClass('.opacity');
}, function(){
$('#huh').removeClass('.opacity');
});
});
</script>
.opacity {
opacity: 0.3;
}
The addClass() method adds one or more class names to the selected elements. This method does not remove existing class attributes, it only adds one or more class names to the class attribute. Tip: To add more than one class, separate the class names with spaces.
Using . add() method: This method is used to add a class name to the selected element. Syntax: element.
jQuery hasClass() Method The hasClass() method checks if any of the selected elements have a specified class name. If ANY of the selected elements has the specified class name, this method will return "true".
Use it without dot:
$(function(){
$('#menuNav').hover(function(){
$('#huh').addClass('opacity');
}, function(){
$('#huh').removeClass('opacity');
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With