7 Replies - 2414 Views - Last Post: 27 September 2009 - 09:22 PM

#1 dkean  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 24-September 09

moving a DIV with JavaScript

Post icon  Posted 24 September 2009 - 09:15 PM

How do I go about moving a general DIV with Javascript?
Is This A Good Question/Topic? 0
  • +

Replies To: moving a DIV with JavaScript

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,145
  • Joined: 07-September 06

Re: moving a DIV with JavaScript

Posted 24 September 2009 - 09:37 PM

You will have to position the div absolutely and then modify the posTop and posLeft values with javascript. If you want to take an easier route, you can just use a library like jQuery, which has all this premade for you so you just call a function and it does all the work.
Was This Post Helpful? 1
  • +
  • -

#3 dkean  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 24-September 09

Re: moving a DIV with JavaScript

Posted 24 September 2009 - 10:25 PM

View PostBetaWar, on 24 Sep, 2009 - 08:37 PM, said:

You will have to position the div absolutely and then modify the posTop and posLeft values with javascript. If you want to take an easier route, you can just use a library like jQuery, which has all this premade for you so you just call a function and it does all the work.


I am sure that from your perspective it is much easier. I, however, am a beginner in Javascripting. I found the jQuery.js file downloaded it and I can plainly say that I have no clue where to find those functions. The language does not even look like the Javascript I have seen in the past!

This is like just another language on top of PHP, Javascript MySQL, Ajax, ASP and a horde of other languages and dialects I want to learn. AHOY!

Maybe you could tell me exactly how to position the DIVs absolutely. And I can start from my level (The crawl space). I just need to know how to perceive the window from Javascript's perspective. From there I can make my own functions for relative motion/positioning etc...
Was This Post Helpful? 0
  • +
  • -

#4 dkean  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 24-September 09

Re: moving a DIV with JavaScript

Posted 25 September 2009 - 01:49 AM

View PostBetaWar, on 24 Sep, 2009 - 08:37 PM, said:

You will have to position the div absolutely and then modify the posTop and posLeft values with javascript. If you want to take an easier route, you can just use a library like jQuery, which has all this premade for you so you just call a function and it does all the work.



And thanx... I have to do some studying, but jQuery looks great now...
Was This Post Helpful? 0
  • +
  • -

#5 Wimpy  Icon User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: moving a DIV with JavaScript

Posted 25 September 2009 - 09:30 AM

To absolutely position an html element you would have to use CSS either by using the style-attribute of the element <element style="position: absolute;" /> or in a CSS clause or in an external CSS file. :)

I would definitely use jQuery myself, today. But if you are a beginner at Javascript I would strongly recommend that you did this yourself for the sake of learning how to do it the hard way! :)

To learn more about jQuery and moving stuff around in particular I would suggest you to take a look at the jQuery UI demonstrations:
http://jqueryui.com/demos/draggable/

Hope it helps! :)
Was This Post Helpful? 1
  • +
  • -

#6 dkean  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 24-September 09

Re: moving a DIV with JavaScript

Posted 26 September 2009 - 09:44 PM

View PostWimpy, on 25 Sep, 2009 - 08:30 AM, said:

To absolutely position an html element you would have to use CSS either by using the style-attribute of the element <element style="position: absolute;" /> or in a CSS clause or in an external CSS file. :)

I would definitely use jQuery myself, today. But if you are a beginner at Javascript I would strongly recommend that you did this yourself for the sake of learning how to do it the hard way! :)

To learn more about jQuery and moving stuff around in particular I would suggest you to take a look at the jQuery UI demonstrations:
http://jqueryui.com/demos/draggable/

Hope it helps! :)


Great site dude... Great... Thanx
Was This Post Helpful? 0
  • +
  • -

#7 Wimpy  Icon User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: moving a DIV with JavaScript

Posted 27 September 2009 - 04:30 AM

No problem, happy to help!

Just wanted to add that everything you might want to do with jQuery almost always already have a finished plug-in for it... Browse through the plug-in repository at jquery.com when you are looking for something in particular! Saves you time for both implementing and testing it yourself! :)

jQuery Plug-in Repository: http://plugins.jquery.com/

:)

View Postdkean, on 27 Sep, 2009 - 06:44 AM, said:

Great site dude... Great... Thanx

Was This Post Helpful? 0
  • +
  • -

#8 dkean  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 24-September 09

Re: moving a DIV with JavaScript

Posted 27 September 2009 - 09:22 PM

View PostWimpy, on 27 Sep, 2009 - 03:30 AM, said:

No problem, happy to help!

Just wanted to add that everything you might want to do with jQuery almost always already have a finished plug-in for it... Browse through the plug-in repository at jquery.com when you are looking for something in particular! Saves you time for both implementing and testing it yourself! :)

jQuery Plug-in Repository: http://plugins.jquery.com/

:)

View Postdkean, on 27 Sep, 2009 - 06:44 AM, said:

Great site dude... Great... Thanx


My biggest problem, now, is to look past the possibilities with this gold mine of information you guys have introduced me to, and start using things.

Deliriously yours...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1