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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:10:25+00:00 2026-05-27T09:10:25+00:00

How to select elements based on XY coordinates and not with mouse drag with

  • 0

How to select elements based on XY coordinates and not with mouse drag with jquery?
enter image description here

  • 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-27T09:10:25+00:00Added an answer on May 27, 2026 at 9:10 am

    The jQuery plugin, as shown below, will select all elements which are (partially) at position >= x and >= y.

    (function($){
        $.fn.filterXY = function(x, y){
            return this.filter(function(){
                var $this = $(this),
                    offset = $this.offset(),
                    width = $this.width(),
                    height = $this.height();
                return offset.left + width >= x
                    && offset.top + height >= y;
            });
        }
    })(jQuery);
    

    Examples:

    $("*").filterXY(0,0);
    $("div").filterXY(100, 0);
    

    Update: Plugin to filter all elements between x1 and x2

    Demo: http://jsfiddle.net/yx4sN/7/

    (function($){
        $.fn.inRangeX = function(x1, x2){
            // Accepting selectors and DOM elements
            if (typeof x1 == "string" && +x1 != x1 || x1 instanceof Element) {
                x1 = $(x1);
            }
            if (typeof x2 == "string" && +x1 != x1 || x1 instanceof Element) {
                x2 = $(x2);
            }
            // Accepting jQuery objects
            if (x1 instanceof $) {
                x1 = x1.offset().left;
            }
            if (x2 instanceof $) {
                x2 = x2.offset().left;
            }
            x1 = +x1;
            x2 = +x2;
    
            // Make sure that x1 < x2
            if (x1 > x2) {
                var x = x1;
                x1 = x2;
                x2 = x;
            }
            return this.filter(function(){
                var $this = $(this),
                    offset = $this.offset(),
                    rightSide = $this.width() + offset.left;
                return offset.left >= x1
                      && rightSide <= x2;
            });
        }
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to us jQuery to select a collection of form elements based
I need to select a specific grange of jquery elements based on there index
Is there an easy and straight-forward method to select elements based on their data
In trying to select elements that have any attributes, the following throws a jQuery
I need to select elements based on values stored in an element's .data() object.
Possible Duplicate: xpath select elements between two nodes based on this html i need
I'm trying to select a number of elements from a mysql table based on
I am hiding some elements based on the current value of a select field
I am trying to select elements that do not match a given attribute id.
I'm trying to select elements based on the attributes of sub a element of

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.