How to get image to pulse with opacity with JQuery

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-06-09T18:32:21Z Indexed on 2010/06/09 18:52 UTC
Read the original article Hit count: 570

Filed under:
|
|
|
|

I am trying to get an image to change opacity smoothly over a duration of time. Here's the code I have for it.

<script type="text/javascript">
pulsem(elementid){
    var element = document.getElementById(elementid)
    jquery(element).pulse({opacity: [0,1]}, 
{    duration: 100, // duration of EACH individual animation    
     times: 3, // Will go three times through the pulse array [0,1]   
     easing: 'linear', // easing function for each individual animation    
     complete: function() {        alert("I'm done pulsing!");    }
})
</script>


<a href="city.htm"><img src="waterloo.png" onmouseover="javascript:pulsem("waterloo")" border="0" class="env" id="waterloo"/></a>

Also, is there a way for this to happen automatically without the need of a mouseover? Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery