Having troubles having an animation change on click
Hey, still fairly new to jquery (and javascript in general), and I could use some advice on a (presumably) basic function I've been trying to write.
The page runs a basic slideUp / fadeOut > slideUp / fadeIn animation on a delay, but I want the user to be able to skip all of that by clicking on the image (or pretty much wherever, I'm not picky at this point). The code I have so far is:
- $(document).ready(function(){
- $('#wrapper').click(function(){
- $('#wrapper').data('clicked', true);
- alert('this is an alert');
- });
- if($('#wrapper').data('clicked')){
- $('#imagepos').slideUp(500).fadeOut(500);
- $('#contentpos').slideUp(500).fadeIn(500);
- } else {
- $('#imagepos').delay(8000).slideUp(2000).fadeOut(2000);
- $('#contentpos').delay(8000).slideUp(2000).fadeIn(5000);
- }
- });