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

  • Home
  • SEARCH
  • 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 7900489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:59:01+00:00 2026-06-03T08:59:01+00:00

When I click with my left-button it should works like the image below. But

  • 0

When I click with my left-button it should works like the image below.

enter image description here

But instead, my code is doing this.

enter image description here

I made an example (see the fiddle below). As you can see in the image, my current problem is:

All the above and below (not only the first row) are changing too.

In my fiddle example, I’m using .css('background-color', 'red') to test it.

Here is my fiddle.

I gathered information in those two posts.

  • jQuery x y document coordinates of DOM object
  • jQuery: get elements above a given ‘y’ position
  • 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-03T08:59:02+00:00Added an answer on June 3, 2026 at 8:59 am

    Dont know what you rally want but try this:

    $.expr[':'].xy = function (obj, index, meta, stack) {
        var xy = meta[3].split(',');
        var x = xy[0];
        var y = xy[1];
        var el = $(obj);
        var el_offset = el.offset();
        return el_offset.left == y && (el_offset.top-el.height() == x || el_offset.top+el.height() == x);
    }
    

    working example

    UPDATE:

    hmm you can select all of them like this:

    $.expr[':'].xy = function (obj, index, meta, stack) {
        var xy = meta[3].split(',');
        var y = xy[0];
        var x = xy[1];
        var el = $(obj);
        var el_offset = el.offset();
        // check for top and bottom 3 blocks
        if ((el_offset.top-el.height() == y || el_offset.top+el.height() == y) &&  (el_offset.left+el.width() == x || el_offset.left == x || el_offset.left-el.width() == x))
            return true;
        // left and right
        else if (el_offset.top == y && (el_offset.left+el.width() == x || el_offset.left-el.width() == x))
            return true;
    
        return false;
    }
    

    and then do like this:

    $(document).ready(function myfunction() {
    
        $('.content').on("click", function () {
            var obj_left = $(this).offset().left;
            var obj_top = $(this).offset().top;
    
            $('#wrap').find('.content:xy(' + obj_top + ',' + obj_left + ')').css('background-color', 'red');
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the below code works fine but my requirement is little different then what it
How to set Visual Studio 2008, so when I click left mouse button while
Is it possible to handle such events as: Ctrl + mouse left button click;
This is my code currently: $(function() { $('#header_left').click(function(){ $('#header_left_info').fadeOut('fast'); $('#header_left').fadeOut('fast'); $('#header_left_back').delay(250).fadeIn('fast'); }); }); (the
On click (animate) slide to left and go last with z-index. the eg below
I have a function in jquery: $('#map').click(function(e) { var posX = $(this).offset().left, posY =
The code below has (at least) two problems: the Copy button doesn't update the
I am using following code to create a list dynamically. It works fine but
This should be fairly straight forward but is proving not to be. I want
This might be a simple question, but am trying to access a button inside

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.