Different behavior in Chrome and IE9
I am fairly new to jQuery and am attempting to catch the click event to close a menu launched by a button.
I have the following code that works on Chrome but fails on the if( $target.is($search_button) ) line in IE9 and therefore falls through to always hide the control in question. In other words, the menus attached to the buttons never open in IE.
I would appreciate any comments on my code as well as any suggestions as to why Chrome works but IE doesn't(no Microsoft jokes please)
There are actually two buttons I need to worry about, hence the somewhat convoluted code.
$(document).one().click(function () {
var $target = $(event.target);
var $search = $("#search");
var $search_button = $("#search_button");
var $help = $("#help");
var $help_button = $("#help_button");
if ($target.is($search_button)) {
$search.show();
}
else if ($target.is($help_button) || $target.parents().index($help_button) == 0) {
$help.show();
}
else if ($target.parents().index($search) == -1 && $search.is(":visible")) {
$search.hide();
}
else if ($target.parents().index($help) == -1 && $help.is(":visible")) {
$help.hide();
}
});