I'm trying to fade images in and out instead of them instantly changing (as they currently do).
See my codepen for a working example: http://codepen.io/jsegarra/pen/ExCrj If you press a number the image will change.
I have a dynamic page and when someone gets to the projects section of the page there are 48 different projects to view. The codepen is an example of what one of those projects might look like. I know the inline onclick function is probably not the best way to do this, but every jQuery function i have attempted(many) have not worked correctly.
I would love one jQuery function that would control the changing of the image across all 48 sections, as I have jQuery controlling most of the page. I originally set up the HTML this way, which works, but the images change instantly, I need them to fade in/out.
I've tried a number of things, including just adding .fadeIn()/Out() somewhere in that inline function.
Then I took out the src of those images from the li and created new divs inside the encompassing div:
<div class="nextImage secondImage">
<img src="document.getElementById('br_img').src = 'http://kerlabs.net/wp-content/uploads/2014/03/Scenic-Waterfall-HD-Wallpaper.jpg'" />
</div>
etc. for all 4 and added display: none; for those in the CSS to go with this jQuery function and added display:
$(document).ready(function () {
$('.one').click(function () {
$('.shownImage').fadeOut(300, function () {
$('.firstImage').fadeIn(500);
});
});
$('.two').click(function () {
$('.shownImage').fadeOut(300, function () {
$('.secondImage').fadeIn(500);
});
});
$('.three').click(function () {
$('.shownImage').fadeOut(300, function () {
$('.thirdImage').fadeIn(500);
});
});
$('.four').click(function () {
$('.shownImage').fadeOut(300, function () {
$('.fourthImage').fadeIn(500);
});
});
});
That didn't do anything, and neither did the 20 variations of it that I've tried. I'm basically stuck and need inspiration and help. I might look into CSS3 animations also to get this to work, because the HTML works, just needs little effect. Thanks for any help!