Reputation: 151
I am playing about with the .animate function in jQuery, I'm fairly new to the function, however for some reason, I can't get it to work. Not sure where I might be going wrong.
First, I define the script in the body tags...
<script>
$('.rgt_btn').click(function() {
$('.ovlBox').animate({
opacity: 0.0 // I hope this will work? I'm trying to fade this box out, and fade in another... Or something along lines of a carousel.
}, {
duration: 2000,
specialEasing: {
width: 'linear',
height: 'easeOutBounce'
},
complete: function() {
$(this).after('// I'm trying to display here another box, but not sure how I can achieve this? The entire <div> box code is quite long to paste here.');
}
});
});
</script>
Just below it, I have my box...
<div id="lmovlb" class="ovlBox"> <!-- Content, lots of it... -->
<div style="display: block;" class="lft_btn"></div>
<div style="display: block;" class="rgt_btn"></div>
</div>
Upvotes: 0
Views: 131
Reputation:
Here is a jsfiddle that demonstrates (excuse the terrible css). Note that as I said before, you should wrap your code in a function and call it on page load. Additionally, use an external js file, if possible.
Here is an example of how this can be accomplished:
var yourFunc = function() {
$('.rgt_btn').click(function() {
$('.ovlBox').animate({
opacity: 0.0
}, {
duration: 2000,
specialEasing: {
width: 'linear',
height: 'easeOutBounce'
},
complete: function() {
alert("hello");
}
});
});
}
$(document).ready(yourFunc);
Upvotes: 3