making my own drag and drop effect.
Hi, I am trying to make my own drag and drop effect using just jquery and not jquery.ui
here is the code I have so far:
- var x_pos;
- var y_pos;
- $(document).mousemove(function(rp){
- x_pos = rp.pageX;
- y_pos = rp.pageY;
- });
- $("*").mousedown(function(ramskin){
- var taz = [id:of element_this line isn't posted...in script it's coded to grab element id that been clicked];
- if(ramskin.which == '1'){
- $(document).mousemove(function(){
- $(taz).css({ \"left\": x_pos, \"top\": y_pos });
- $(\"*\").click(function(){
- $(document).unbind('mousemove');
- $(document).bind('mousemove');
- });
- });
- }
- if(ramskin.which == '3'){
- open a div when clicked.
- }
- });
I currently can click on a image and then drag it and then drop it but can't click on it again to drag it.
Plus if I click anything else like a div or text the element would appear far right rather then be right under the users mouse. Why is that???