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 11, 2016 at 7:48 pm
#240462
Shikkediel
Participant
Reading the site, I understand it might be quite impossible for you to create a Codepen. But I really have no idea which element should be selected for the screen reader. You could give this variation a go :
jQuery(document).ready(function($) {
$('.bbp-admin-links:even').css({position: 'absolute', right: 380});
$('.bbp-meta ul.bbp_custom_links_menu li.parent > a').click(function(e) {
var options = $(this).closest('ul');
if (options.attr('aria-expanded') == 'true') options.attr('aria-expanded', 'false');
else options.attr('aria-expanded', 'true');
$(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();
$('.bbp_custom_links_menu').attr('aria-expanded', 'false');
}
});
});