Close menu on click outside of menu area
Thanks for the input. When firing the click event using
I always ended up in an endless recursion, although I don't have a clue why...
But I think I found a pretty simple solution. At least it seams to work so far:
I will test it a little more before going live.
cme
Code:
$('li.accordeonck.open').trigger('click');
But I think I found a pretty simple solution. At least it seams to work so far:
Code:
$( "body" ).click(function( event ) {
if(!event.target.hasClass("toggler")){
$('li.accordeonck.open').removeClass('open');
$('ul.content_1').hide();
}
});
I will test it a little more before going live.
cme
by cme
Please Log in or Create an account to join the conversation.
For some reason not working on iPads. Desktops and android tablets are fine.
I extended the if condition a little bit in order to keep the menu open until a new page is loaded if a link is clicked.
cme
I extended the if condition a little bit in order to keep the menu open until a new page is loaded if a link is clicked.
Code:
<script type="text/javascript">jQuery(function($){
$( "body" ).click(function( event ) {
if(!event.target.hasClass("toggler")&&event.target.nodeName!="A"){
$('li.accordeonck.open').removeClass('open');
$('ul.content_1').hide();
}
});
});</script>
cme
Last Edit:8 years 7 months ago
by cme
Last edit: 8 years 7 months ago by cme.
Please Log in or Create an account to join the conversation.
Replied by ced1870 on topic Close menu on click outside of menu area
Posted 8 years 6 months ago #30011
thank you for sharing your solution. As you can see, it is not so easy to do that
Joomlack Webmaster and Developer
by ced1870
Please Log in or Create an account to join the conversation.
Time to create page: 0.672 seconds