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

138
Views
How to exclude the window.getSelection() to includes the tooltip text when selecting html text in Chrome (It is working fine in Firefox)

I had the following code

Html example

<p>
  <span class="highlighting-tooltip>I BEAT COVID
    <span class="highlighting-tooltiptext">CAPITAL ERROR</span>
  </span>
</p>

CSS File

.highlighting-tooltip {
    position: relative;
    display: inline-block;
}
.highlighting-tooltip .highlighting-tooltiptext {
    visibility: hidden;
    background-color: #333;
    color: #fff;
    margin-left: -90px;
    top:100%;
    margin-top:40px;
    user-select: none;
    z-index: 1;
}

.highlighting-tooltip:hover .highlighting-tooltiptext {
    visibility: visible;
}

In above the text "I BEAT COVID" is displayed in html and when hover with mouse pointer the tooltip is displayed. The problem is when I select this text "I BEAT COVID" and get the output of window.getSelection() then it also includes the text "CAPITAL ERROR"

I checked it is working fine in firefox and "CAPITAL ERROR" is not included only the chrome is giving this error. Is there any way in chrome to avoid this tooltip text to get included in window.getSelection() ?

about 4 years ago · Juan Pablo Isaza
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!