Skip to content

Instantly share code, notes, and snippets.

@alexvas123
Created September 25, 2016 07:25
Show Gist options
  • Save alexvas123/2aa98f355ea71c596d36738f79728eb7 to your computer and use it in GitHub Desktop.
Save alexvas123/2aa98f355ea71c596d36738f79728eb7 to your computer and use it in GitHub Desktop.
Javascript Buttons and Content
// BUTTONS AND CONTENT
$("li.button").on("click", function (event) {
event.preventDefault();
var name = $(this).attr("data-story"); // Gets attr data-storey from button
var parent = $(this).closest(".content"); // Finds parent of the button
var container = $(parent).find(".container"); // Finds child with content
var videoLink = $(this).find("a").attr("href"); // Finds li > a link to video
$(container).children().fadeOut("slow"); // Hides content
$('iframe[data-story="' + name + '"]').attr("src", videoLink); // Links to video
$('div[data-story="' + name + '"]').fadeIn("slow"); // Makes content visible
new Vivus(name, details); // Portrait animation in the first section
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment