Last active
October 27, 2016 10:14
-
-
Save bitkorn/fe1061cfc30c9cd2bd15cc7d921cd10b to your computer and use it in GitHub Desktop.
toggle W3.CSS dropdown with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toggleW3(id) { | |
var toggleme = $("#" + id); | |
toggleme.css("z-index", 5); | |
if (!toggleme.hasClass("w3-show")) { | |
$("#" + id).addClass("w3-show"); | |
$("#" + id).css("z-index", "1"); | |
$("#" + id).removeClass("w3-hide"); | |
var elementId = ""; | |
$(".w3-dropdown-content").each(function (index, element) { | |
elementId = $(element).attr("id"); | |
if (elementId != id) { | |
$(element).addClass("w3-hide"); | |
$(element).removeClass("w3-show"); | |
} | |
}); | |
} else { | |
$("#" + id).addClass("w3-hide"); | |
$("#" + id).removeClass("w3-show"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment