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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:49:59+00:00 2026-06-05T21:49:59+00:00

I need to show a div positioned relative to where the link is that

  • 0

I need to show a div positioned relative to where the link is that the user clicks.

The link the user clicks is actually generated dynamically as well and looks like so.

<td><a href='' onClick="showDiv(14)">Show the div</a></td> 

(14 is the ID of the record in the row which I will need for the DIV)

Here’s my showDiv() function

function showDiv(id){

// get the mouse coordinates of the link
var mouseX;
var mouseY;

$(document).mousemove( function(e) {
   mouseX = e.pageX; 
   mouseY = e.pageY;
   $('#myDiv').show().css({'top':mouseY,'left':mouseX});
});  
}

This is showing my DIV when executed, but not relative. I feel I am a bit off here, JS is not my strength.

  • 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-05T21:50:00+00:00Added an answer on June 5, 2026 at 9:50 pm

    I’ve went ahead and made a jsFiddle with a solution to your problem.

    The key is to bind your function to the click handler:

    Javascript

    $("selector to your element").click(function(e) {
       mouseX = e.pageX;
       mouseY = e.pageY;
    
      $("#myDiv").show().css({'top':mouseY,'left':mouseX});
    });
    

    Also as documented in the fiddle, the div should be hidden with display:none;

    I went ahead and extended this a little myself, because perhaps you would like to hide the div by clicking the link again? You can find that in this fiddle.

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

Sidebar

Related Questions

I need to show for every link, dynamically some text with Java-Script (jQuery). The
I need to implement a dynamic div that pops up for each user. I
<div id=parent style=overflow:hidden; position:relative;> <div id=child style=position:absolute;> </div> </div> I need to show child
I need to hide the present div and show next hide here is my
I need a jquery slideshow with div popup i want to show my image
I need to show more than one report on a Page like Classic Report,
I need to show a DIV containing a slideshow only when the DOM is
I'm new to jQuery and need some help to show and hide a div
I have a scrollable area that contains popup menus. Conceptually, something like this: <div
I use jQuery UI tabs as my container div. Now I need to show

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.