문제

I am new to JavaScript and jQuery. I have trouble in my new project. I want to need a image is bouncing. I got a script from net. But This function is only for jumping on the click.I want its jumping when the site is loaded. Please help me.

Link http://www.tycoonlabs.com/help/bouncing%20-%20Copy.html

This is my script

<SCRIPT>
$(function(){
    $('#bouncy1').click(function () {
          $(this).effect("bounce", { times:5 }, 300);
    });
});
</SCRIPT>

Thanks and Regards

도움이 되었습니까?

해결책

If you want to have it bounce while something is happening and then stop it, you could use setInterval

var interval = setInterval(function(){ 
    jQuery('#someId').effect('bounce', {times: 5}, 300);
}, 500); // every half second

// Do some stuff to load up your site;        

clearInterval(interval); // Stop the bounce interval

You may want to adjust the times parameter and the delay to meet your needs and effect.

다른 팁

Try this:

<script>
    $(function(){
        function bounceObject(obj)
        {
            obj.effect("bounce", { times:5 }, 300);
        }
        bounceObject($('#bouncy1'));
        $('#bouncy1').click(function () {
            bounceObject($(this));
        });
    });
</script>

this works well

function bounce(){
    $('#test').effect( "bounce", "slow", bounce);
}
bounce();

http://jsfiddle.net/xGe2D/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top