My menu JavaScript function now opens with a click and closes with a click. I want it to open with a click and close when the mouse leaves the button.
$("#theme_select").click(function() {
if (theme_list_open == true) {
$(".center ul li ul").hide();
theme_list_open = false;
} else {
$(".center ul li ul").show();
theme_list_open = true;
}
return false;
});
I made changes with one person and fixed the top problem, but when I tried to move my mouse to an opened menu item, the menu was closed. See my full script (before the change):
<script type="text/javascript">
var theme_list_open = false;
$(document).ready(function () {
function fixHeight () {
var headerHeight = $("#switcher").height();
$("#iframe").attr("height", (($(window).height() - 1) - headerHeight) + 'px');
}
$(window).resize(function () {
fixHeight();
}).resize();
$("#theme_select").click( function () {
if (theme_list_open == true) {
$(".center ul li ul").hide();
theme_list_open = false;
} else {
$(".center ul li ul").show();
theme_list_open = true;
}
return false;
});
$("#theme_list ul li a").click(function () {
var theme_data = $(this).attr("rel").split(",");
$("li.purchase a").attr("href", theme_data[1]);
$("li.remove_frame a").attr("href", theme_data[0]);
$("#iframe").attr("src", theme_data[0]);
$("#theme_list a#theme_select").text($(this).text());
$(".center ul li ul").hide();
theme_list_open = false;
return false;
});
});
</script>