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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:31:08+00:00 2026-05-11T17:31:08+00:00

i make a class of elements draggable like this jQuery(.drag).draggable(); jQuery(.drop).droppable({ accept: .drag, drop:

  • 0

i make a class of elements draggable like this

jQuery(".drag").draggable();

jQuery(".drop").droppable({
accept: ".drag",

drop: function(ev, ui) {
//do stuff with dropped data

    }
});

now the problem is, i am able to drag the elements out of body, and all over the html. how do i limit the area in which it is draggable?

  • 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-11T17:31:08+00:00Added an answer on May 11, 2026 at 5:31 pm

    http://docs.jquery.com/UI/Draggable#option-containment

    Constrains dragging to within the bounds of the specified element or region. Possible string values: ‘parent’, ‘document’, ‘window’, [x1, y1, x2, y2].

    Example:

    Initialize a draggable with the containment option specified.

    $('.selector').draggable({ containment: 'parent' });
    

    Or in case the problem is that the draggable can be placed all over the place:

    http://docs.jquery.com/UI/Draggable#option-revert

    If set to true, the element will return to its start position when dragging stops. Possible string values: ‘valid’, ‘invalid’. If set to invalid, revert will only occur if the draggable has not been dropped on a droppable. For valid, it’s the other way around.

    And finally, I don’t see you setting the scope of the draggable (Edit: But that won’t fix your problem, the other 2 things above should):

    http://docs.jquery.com/UI/Draggable#option-scope

    Used to group sets of draggable and droppable items, in addition to droppable’s accept option. A draggable with the same scope value as a droppable will be accepted by the droppable.

    Example:

    Initialize a draggable with the scope option specified.

    $('.selector').draggable({ scope: 'tasks' });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 94k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just a technicality, but you do have a window, and… May 11, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer You probably have a couple of options. Beyond what you… May 11, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer Actually, your statement is not completely accurate. SemWeb is not… May 11, 2026 at 6:55 pm

Related Questions

I'm new to JQuery, so this is probably a very dumb question. I've used
Thanks for the three excellent answers which all identified my problem of using "onclick
I am trying to make a navigation that uses simple unordered lists to list
I wrote the following method. public T GetByID(int id) { var dbcontext = DB;
EDIT: As of Java 8, static methods are now allowed in interfaces. Here's the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.