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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:08:31+00:00 2026-06-06T09:08:31+00:00

I want to use a drag to select feature, but rather than select a

  • 0

I want to use a drag to select feature, but rather than select a square area on screen, and select anything within that square, I want to select any element between my initial choice and the one I release the click on.

This is best explained visually. I do not want to do this:

What I don't want to do

Instead I want to do this:

What I want to do

  • 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-06-06T09:08:32+00:00Added an answer on June 6, 2026 at 9:08 am

    After the previous failed attempt I’ve now come up with a working solution. It would appear that jQuery UI selectable is not suitable, as it uses that rectangular selection, so I’ve had to roll my own.

    In the example below (see jsFiddle for full code), the selectable elements are a.date. These elements should have position: relative set.

    Firstly, I append a child element with class .drag-proxy. This is positioned absolutely, and covers the same area as the child. It’s got no content so it sits transparently above.

    These proxy elements are made draggable and droppable.

    When the element is dragged and dropped onto another element, it is moved back to its starting point (so that subsequent selections work).

    Then we cycle through all the proxy elements, indentifying the elements in the selection range, and then setting a class on the parent a.date element.

    $(function() {
      $('a.date').each(function() {
      $(this).append('<a href="' + $(this).attr('href') + '" class="drag-proxy" id="proxy_' + $(this).attr('id') + '"></a>');
      });
    
      var $currentlyDragged;
    
      $('.drag-proxy').draggable({
        start: function() {
          $currentlyDragged = $(this);
        },
        // Once drag has finished, return the drag-proxy to its original position
        stop: function() { 
          $(this).css('top', 0).css('left', 0);
          $currentlyDragged = null;
        }
      });
    
      $('.drag-proxy').droppable({
        over: function(e, ui) {
          var from_id = $currentlyDragged.attr('id');
          var to_id = $(this).attr('id');
    
          $('.date').removeClass('selected');
    
          var started = selecting = false;
          $('.drag-proxy').each(function() {
            var $this = $(this);
            var this_id = $this.attr('id');
            if (started === false && (this_id == from_id || this_id == to_id)) {
              selecting = true;
            }
            if (selecting) {
              $this.parent().addClass('selected');
              if (started === true && (this_id == from_id || this_id == to_id)) {
                selecting = false;
              }
            }
            if (started === false && (this_id == from_id || this_id == to_id)) {
              started = true;
            }
          });
        },
    
        drop: function(e, ui) {
          // do whatever you need to do once selection ends
        }
      });
    
    
    });
    ​
    

    See the jsFiddle for the full example.

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

Sidebar

Related Questions

I want use JQuery mobile for the front-end of my mobile application, but I
I have a transaction log file in CSV format that I want use to
I have a easy select tag: <select> <option></option> <option></option> </select> Then I want use
I want to use the look of standard buttons on my page, but I
I know that I can use the JQueryUI Drag and Drop with some of
I want to make a tool that takes some filenames as parameters, but when
If i want to use Linq-SQL i also have to drag the DB Table
I want to use Jquery to implement a page that contains js from quotemedia.com.
I want to use Jquery UI Sortable to implement drag-drop and sortable display. In
I am going to use SQL Server in my project, for that I want

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.