Skip to content

Instantly share code, notes, and snippets.

@pablocattaneo
Created June 24, 2015 15:59
Show Gist options
  • Save pablocattaneo/96e07c798c7144460059 to your computer and use it in GitHub Desktop.
Save pablocattaneo/96e07c798c7144460059 to your computer and use it in GitHub Desktop.
<script>
/* Menu desplegable para mobile*/
(function($) {
$.fn.collapsable = function(options) {
// iterate and reformat each matched element
return this.each(function() {
// cache this:
var obj = $(this);
var tree = obj.next("div[class^='menu-'"); // El elemento que contenga el menú a ocultar y mostar
obj.click(function(){
if( obj.is(':visible') ){ tree.toggle();}
});
$(window).resize(function(){
if ( $(window).width() <= 800 ){tree.attr('style','');};
});
});
};
})(jQuery);
$('selector del elemento que despliega el contenido ').collapsable();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment