Andrey von Emme Andrey von Emme - 5 months ago 16
jQuery Question

Jquery Animate lasting for certain amount of time

I am trying to have jQuery animate function only last for a couple seconds and the revert back to the original item.

<button id="clickMe"> Click </button>
<div id="target"> Target </div>


and the Jquery:

$(document).ready(function(){
$('#clickMe').click(function(){
$('#target').animate({opacity: 0.1}, 'slow');
});
});


How would I make this effect only last for say two seconds? Thanks

Answer

This help you :

<script>
        $(document).ready(function(){
        $('#clickMe').click(function(){
        $('#target').animate({opacity: 0.1}, 2000).animate({opacity: 1});
          });
        });
</script>