Home › Forums › JavaScript › Close menu on click of Options button and outside of container › Reply To: Close menu on click of Options button and outside of container
April 10, 2016 at 12:06 pm
#240398
Shikkediel
Participant
You have two options here – revert all listeners to clicks (these’ll work on touch devices) or include touch events.
jQuery(document).ready(function($) {
$('.bbp-admin-links:even').css({position: 'absolute', right: '380px'});
$('.bbp-meta ul.bbp_custom_links_menu li.parent > a').click(function(e) {
$(this).next('.bbp_custom_links_submenu').toggle();
e.preventDefault();
e.stopPropagation();
});
$(document).click(function(e) {
if (!$(e.target).closest('.bbp_custom_links_submenu').length) {
$('.bbp_custom_links_submenu').hide();
}
});
});
jQuery(document).ready(function($) {
$('.bbp-admin-links:even').css({position: 'absolute', right: '380px'});
$('.bbp-meta ul.bbp_custom_links_menu li.parent > a').click(function(e) {
$(this).next('.bbp_custom_links_submenu').toggle();
e.preventDefault();
})
.on('mouseup touchend', function(e) {
e.stopPropagation();
});
$(document).on('mouseup touchend', function(e) {
if ($(!(e.target).closest('.bbp_custom_links_submenu').length) {
$('.bbp_custom_links_submenu').hide();
}
});
});
From the top of my head, that is.