Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:13:09+00:00 2026-05-24T22:13:09+00:00

I found this function to make my divs draggable and it works fine. right

  • 0

I found this function to make my divs draggable and it works fine. right now if i have my mouse anywhere on the div it drags, but i only want it to drag the div if my mouse is on the rd_header div. here is the function

        var makeDraggable = function(element) {

            element = jQuery(element);
            var move = function(event) {
                if(element.data('mouseMove')) {

                    var changeX = event.clientX - element.data('mouseX');
                    var changeY = event.clientY - element.data('mouseY');

                    var newX = parseInt(element.css('left')) + changeX;
                    var newY = parseInt(element.css('top')) + changeY;

                    element.css('left', newX);
                    element.css('top', newY);

                    element.data('mouseX', event.clientX);
                    element.data('mouseY', event.clientY);
                }
            }

            element.mousedown(function(event) {
                element.data('mouseMove', true);
                element.data('mouseX', event.clientX);
                element.data('mouseY', event.clientY);
            });

            element.parents(':last').mouseup(function() {
                element.data('mouseMove', false);
            });

            element.mouseout(move);
            element.mousemove(move);
        }

and i call it with this

makeDraggable(jQuery('#rd_main'));

i tried calling iot on the header div instead and changing the function variables element. to element.closest(‘div’) but had no luck. i would appreciate any help
here is my divs

<div id="rd_main">
    <div class="rd_header">Action Log</div>
    <div id="rd_logdiv" class="sb"></div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:13:10+00:00Added an answer on May 24, 2026 at 10:13 pm
    makeDraggable('#rd_main', 'rd_header');
    

    Then update your function with this:

    var makeDraggable = function(element, triggerClass) {
        element = $(element);
    
        var move = function(event) {
                if (element.data('mouseMove') && isAvailable) {
                    var changeX = event.clientX - element.data('mouseX');
                    var changeY = event.clientY - element.data('mouseY');
    
                    var newX = parseInt(element.css('left')) + changeX;
                    var newY = parseInt(element.css('top')) + changeY;
    
                    element.css('left', newX);
                    element.css('top', newY);
    
                    element.data('mouseX', event.clientX);
                    element.data('mouseY', event.clientY);
                }
            },
            isAvailable = false;
    
        element.mousedown(function(event) {
            var target = $(event.target);
    
            isAvailable = target.hasClass(triggerClass) || target.closest('.' + triggerClass); //Check if we over wanted element
            element.data('mouseMove', true);
            element.data('mouseX', event.clientX);
            element.data('mouseY', event.clientY);
        });
    
        element.parents(':last').mouseup(function() {
            element.data('mouseMove', false);
        });
    
        element.mouseout(move);
        element.mousemove(move);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To make div s clickable I use this: $(.clickable).click(function (event) { window.location = $(this).find('a').attr('href');
Yesterday I found this function: function clone(obj) { return typeof obj === 'undefined' ?
I found this from C++FAQ Generally, No. From a member function or friend of
I'm trying to find any reference for this function, but I haven't found anything.
In an app I'm profiling, I found that in some scenarios this function is
I'm looking for a javascript version of PHP's html_entity_decode . I found this: function
I found this function that does an AWESOME job (IMHO): http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl /** * Get
Anyone know why this keeps returning a blank image? I found this function here
Linux has this nice function dprintf : The functions dprintf() and vdprintf() (as found
I found this thread which basically has the same issue I have. But their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.