Jump to content

jQuery: Stop animation at specific css value?


Jared

Recommended Posts

I have a div animated by incremented margin-left when the user clicks a button. I would like to force the animation to stop at a specific margin-left value and callback a different animation. So if the user tries to click too far it prevents them from doing so. Suggestions? I'd like to do it with margin because it'd be easier to edit later, but if I have to use .position.left as a variable, I'll take the code for that just as well. Here's a wacky selector I tried, to no avail, if it helps convey my intention: $('.slidingDiv[style*=margin-left:80px]').stop().animate(.....); I didn't bind it to a .click because I want to be able to stop any-size div at any given point rather than map it out explicitly. Thanks!

Link to comment
Share on other sites

UPDATE: I have finally figured it out. It's taken me a bit of time to realize how often you have to redefine a variable within the function for something like that. If anyone else is interested I'll keep following the post and reply with a sample.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...