jquery - Event triggers outside elements won't fire on tap -


i've set couple of event triggers close specific elements when user clicks outside of them. works great non-mobile devices, on mobile or tablet won't fire. i'm assuming because tap events trigger differently clicks. suggestions on how approach function cover both aspects?

// listen unique event targets       $(document).on( 'click', function(event) {         if (!$(event.target).closest( '.modal .content' ).length) {           $( '.modal' ).fadeout(200);         }         if (!$(event.target).closest( '.language-selector ul' ).length) {           if ( $( '.language-selector' ).is( ':visible') ) {             $( '.language-selector >' ).removeclass('active');           }         }         if (!$(event.target).closest( '.searchbox' ).length) {           if ( $( '.searchfield' ).is( ':visible') ) {             $( '.searchfield' ).removeclass('active').parents( '.searchbox' ).find( 'input[type="submit"]' ).removeclass( 'active' );           }         }       }); 

yes, click , tap distinct events.

you can bind both using jquery selecter syntax (click tap):

// listen unique event targets       $(document).on( 'click tap', function(event) {         if (!$(event.target).closest( '.modal .content' ).length) {           $( '.modal' ).fadeout(200);         } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -