Is there a jQuery method to hide/show elements beside .hide()
/.show()
?
Currently I use:
function showMenu($theMenu) {
$theMenu.css("left", "auto");
return $theMenu; // for chaining
}
function hideMenu($theMenu) {
$theMenu.css("left", "-99999px");
return $theMenu; // for chaining
}
I would prefer to use a built-in jQuery method because I can then use:
$theMenu.show();
But, the built-in method uses display: auto, none
which inhibits screen readers.
Appreciate it.
CodePudding user response:
You can try an alternative to hide()
and show()
functions
function hideMenu($theMenu) {
$theMenu.css('visibility', 'visible');;
return $theMenu;
}
CodePudding user response:
Here are some alternatives:
.fadeOut();
.fadeIn();
.css('opacity', '0.0');
.css('opacity', '1.0');
.css('visibility', 'visible');
.css('visibility', 'hidden');