d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need A Little Jquery/javascript Help
Add Reply New Topic New Poll
Member
Posts: 1,628
Joined: Aug 11 2012
Gold: 628.00
Aug 30 2012 11:59am
im not too good with jquery/javascript, im more of a backend guy, but im trying to make a box move on a button click and stop at a certain position(well make the button hide at that position.

heres kind of what i have:
HTML:
Code
<button onclick = "next()" id="nextbtn">Next</button>

<div id = "scroll_box">
   stuff in here

<div>


Javascript:

Code
function next() {

  $(document).ready(function(){
   $("#scroll_box").animate({"left":"-=400px"}, "slow");
    var offset = $("#scroll_box").offset();
   if ($("#scroll_box").offset.left >= 800px) {
 
   $("#nextbtn").hide();
   
   }
 });
}


it will move (with out that offset code) but im not 100% sure how to get it to stop moving.
any help would be appreciated, if you need anymore info, let me know thanks!

This post was edited by Huayra on Aug 30 2012 12:01pm
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Aug 30 2012 01:51pm
Next time you post, jsfiddle your problem.
Also post the javascript error that you are getting (if you are getting one- you can find javascript errors by using Firebug for Mozilla Firefox or the included Javascript console in Chrome)

http://jsfiddle.net/YABVh/4/

I wrote a few comments, but got tired of that when I figured how much you have to learn. Just make you start using the javascript console.. and use google- all the time.
There is an issue with the script right now- the animation can easily be fiddled with, you will need to make it impossible to click until the animation is complete. Good luck.

This post was edited by eagl3s1ght on Aug 30 2012 01:53pm
Member
Posts: 1,628
Joined: Aug 11 2012
Gold: 628.00
Aug 30 2012 02:09pm
Quote (eagl3s1ght @ Aug 30 2012 01:51pm)
Next time you post, jsfiddle your problem.
Also post the javascript error that you are getting (if you are getting one- you can find javascript errors by using Firebug for Mozilla Firefox or the included Javascript console in Chrome)

http://jsfiddle.net/YABVh/4/

I wrote a few comments, but got tired of that when I figured how much you have to learn. Just make you start using the javascript console.. and use google- all the time.
There is an issue with the script right now- the animation can easily be fiddled with, you will need to make it impossible to click until the animation is complete. Good luck.


hey i appreciate it, i didnt even know that site existed. yea, i still have a lot to learn in javascript. ive done a few mall things, but nothing crazy.

This post was edited by Huayra on Aug 30 2012 02:09pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll