How to Make Submenu apper on Button Click using "toggle" in JQuery

Leave a Comment

If you want to make the submenu <div> appear when you first click the link, then disappear when the link is next clicked. Just swap “toggle” for “hover” like this:
$('#menu').toggle(
function() {
$('#submenu').show();
}, // end first click
function() {
$('#submenu').hide();
} // end second click
); // end toggle

Or, using named functions, like this:
function showSubmenu() {
$('#submenu').show();
}
function hideSubmenu() {
$('#submenu').hide();
}
$('#menu').toggle(showSubmenu, hideSubmenu);

0 comments:

Post a Comment