Variable Visions

Articles jQuery RETURN-FALSE-VS-CLICK-TARGET-EXCLUDE


tutorials - jQuery and Web-Development.

RETURN FALSE VS CLICK TARGET EXCLUDE

Published Sun. Dec. 09, 2012


// When the button class is clicked, slide in a toggling motion the ul and toggle on and off the class buttonstate2 to the class mainmenubutton all while EXCLUDING all anchor tags as triggers to prevent the action when a link is clicked
                    jQuery('.button').click(function(targetexclude) {
                        if( !$(targetexclude.target).is("a") ) {
                            jQuery('ul#mainmenu').slideToggle('slow');
                            jQuery('.mainmenubutton').toggleClass('buttonstate2');
                           
   
                });   
//AS OPPOSED TO


// When the button class is clicked, slide in a toggling motion the ul and toggle on and off the class buttonstate2 to the class mainmenubutton all while INCLUDING all anchor tags as triggers to prevent the anchor tags default action when a link is clicked
                    jQuery('.button').click(function() {
                        jQuery('ul#mainmenu').slideToggle('slow');
                        jQuery('.mainmenubutton').toggleClass('buttonstate2');
                       
                        return false;
                    });