Skip to content

Instantly share code, notes, and snippets.

@icemancast
Created January 14, 2014 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icemancast/8421855 to your computer and use it in GitHub Desktop.
Save icemancast/8421855 to your computer and use it in GitHub Desktop.
// News click switcher
$('li[id*="newsSwitch-"').click(function (evt) {
var speed = 100;
var clickedClass = evt.currentTarget.id;
var clickedNumber = clickedClass.match(/\d/);
var title = document.getElementById('newsSwitch-title-' + clickedNumber).innerHTML;
var description = document.getElementById('newsSwitch-description-' + clickedNumber).innerHTML;
var image = document.getElementById('newsSwitch-image-' + clickedNumber);
image = '<header id="newsImage"><img src="' + image.src + '" class="news-image" width="270" height="164" alt=""/></header>';
$('#current_story_headline').fadeOut(speed, function () {
$(this).html(title).delay(speed).fadeIn(speed);
});
$('#current_story').fadeOut(speed, function () {
$(this).html(description).delay(speed).fadeIn(speed);
});
$('#news_image').fadeOut(speed, function () {
$('#newsImage').remove();
$(this).prepend(image).delay(speed).fadeIn(speed);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment