Created
December 20, 2010 16:34
-
-
Save hay/748596 to your computer and use it in GitHub Desktop.
A jQuery plugin that enables the behaviour of the HTML5 <details> and <summary> elements.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.detailsShim = function() { | |
$("details").each(function() { | |
// Initial state of all elements in <section> | |
var initOpen = ($(this).attr('open') === "true") ? true : false; | |
$(this).children(":not(summary)").each(function() { | |
$(this).toggle(initOpen); | |
}); | |
// Click event on <summary> toggles all elements | |
$("summary").click(function(e) { | |
e.preventDefault(); | |
$(this).nextAll().toggle(); | |
}); | |
}); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment