Skip to content

Instantly share code, notes, and snippets.

@tonyfast
Created February 3, 2015 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tonyfast/77f34f5867df98ca9418 to your computer and use it in GitHub Desktop.
Save tonyfast/77f34f5867df98ca9418 to your computer and use it in GitHub Desktop.
A simple example that dynamically adds slides to a Reveal.js
<head>
<link rel="stylesheet" href="//cdn.jsdelivr.net/g/reveal.js(css/reveal.min.css)">
<script src="//cdn.jsdelivr.net/g/reveal.js,zepto"></script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>Single Horizontal Slide</section>
<section id="blank"></section><!-- Blank slug -->
</div>
</div>
<script>
;(function(){
Reveal.initialize();
//slide deck wrapper
deck = $('#blank').parent();
// a blank is initialized and stored as a variable
wrap = $('#blank').clone()
.attr('id',null)
.prop('outerHTML');
// remove the blank
$('#blank').remove();
// add some slides
newslide(1);
newslide(2);
newslide('Woop,woop');
})();
function newslide(i){
// wrap the new content in the blank
$('<em>Slide added'+i+'</em>').appendTo(deck)
.wrap( wrap );
};
</script>
</body>
@G1305
Copy link

G1305 commented Feb 20, 2018

HOW TO ADD DYNAMIC CONTENTS INSIDE SLIDES?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment