开发者

Jquery Animate DIV

Hi Am using Jquery animate function to animate div content am trying to move div to -top,The problem is not able to stop function its moving to exteme开发者_StackOverflow中文版 top=-10px i wanna move it to in intervals that is onscrolling it should move to -10px of existing height in next interval again it should move to further -10px on movement of scroll


The problem is you are executing the code once so, it move to -10px once you need to execute that code repeatedly after a specific interval. You can do something like this:

$(function(){ setInterval(move,100); });

function move(){ $("#mvup").animate({"top": "-=10px"}, "slow"); }

I think this might help you


I think you're trying to scroll something along with the browser window, I presume?

This could give you a start (I hope this works):

$(document).scroll(function()
{
  $('yourBox').animate({top: $(document).scrollTop() - 10});
});

So I guess that's your original code.

window.onload = function()
{
  var frm = document.getElementById("from").contentWindow;
  frm.onscroll = function(){
    $("#mvup").animate({"top": "-=10px"}, "slow");
  }
}

A few pointers:

  • jQuery has a $(document).ready() function which supersedes the window.onload = ... variable. It is more flexible, easier to work with, and looks cooler.
  • jQuery also has a $('#mvup').scroll() method, so I would do away with your frm.onscroll = ... code.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜