Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
How to Show a div near Cursor position on hover in React js?

I have two Text Items, item1 and item2, and a div with some text inside. I want to keep the div hidden by default but show it at cursor position when I hover on Text item1 or item2. Please check the sample GIF animation in this Link

I tried this in Jquery code inside React. But it gives error.

$(".text-item").mouseenter(function (e) {
  $(".box")
    .css({
      position: "absolute",
      right: e.pageX,
      top: e.pageY,
      display: "block",
    })
    .show();
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this:

import {useState, Fragment} from react;

const [visible, setVisible] = useState(false)

const MyApp = ()=> {
  return ( 
      <Fragment> {
         visible && 
         <div className="hiddenContainer>
            <p>Your hidden text</p>
         </div>
      }
      </Fragment>
      <p onMouseEnter={()=>setVisible(!visible)}>Item 1</p>
      <p onMouseEnter={()=>setVisible(!visible)}>Item 2</p>
    )
  }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!