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 7082623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:04:38+00:00 2026-05-28T07:04:38+00:00

I am using js/jquery to create draggable graph. Graph has two draggable elements that

  • 0

I am using js/jquery to create draggable graph. Graph has two draggable elements that select values on graph based behind. My problem now is that next step would be to be able to multiply up to six graphs on one page, which i did, now when graphs are created dynamically, only way to reference element is by $(this), how will adress both elements in same function?

EDIT:

function drag_function(event, ui) {

    var $selFirst = $(".second :nth-child(1)"),
        $selSecond = $(".second :nth-child(2)"),
        cachedWidth = $selFirst.outerWidth();

    var $firstRightBorder = $selFirst.position().left + 1,
        $secondLeft = $selSecond.position().left,
        diff = $firstRightBorder - $secondLeft;
}

If I use :

function drag_function(event, ui) {

    var $selFirst = $(this),
        $selSecond = $(this),
        cachedWidth = $selFirst.outerWidth();

    var $firstRightBorder = $selFirst.position().left + 1,
        $secondLeft = $selSecond.position().left,
        diff = $firstRightBorder - $secondLeft;
}

also doesnt work??

ANSWER:

 var $selFirst = $(this).parent().children().eq(0),
        $selSecond = $(this).parent().children().eq(1)
  • 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-28T07:04:38+00:00Added an answer on May 28, 2026 at 7:04 am

    It is still not clear what you want to achieve. I guess it is this. Please drag and drop the divs in example given below.

    http://jsfiddle.net/diode/8wxCb/1/

    In event handler functions this and event.currentTarget will refer to the object for which the event has occurred.

    for e.g:

    button1.onclick = function(event){
    
         console.log(this);  // button1
         console.log(event.currentTarget);  // button1
    
    }
    

    So if you add same function as listener to many, in the function you can check

    if(this == button1){
    
    }else if(this == button2){
    
    }
    

    or

    if(this.id == "button1"){
    
    }else if(this.id == "button2"){
    
    }
    

    As you get the object inside the function you can directly read/write it’s properties

    see: http://jsfiddle.net/diode/nZQy6/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JQuery to create a Horizontal Accordion menu (based on the tutorial at
I'm using the JQuery Draggable plugin . I'm trying to create an Image Editing
I am seeing strange behavior of jQuery UI draggable elements using Chrome. In the
I'm trying to create a draggable div (constrained to the x axis) using JQuery
I want to create an application that drops certain elements on other elements, using
i am using a jquery plugin to create some draggable objects. the plugin is
I am interested in using jQuery to create automatic pagination for content based on
I'm using jQuery to create a load of tabs for a web application. I've
I am using jquery to create a custom dropdown with the code below. I
I was using jQuery plugins to create a rounded corner for my <li> ,

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.