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

151
Views
Copy a hiden element to clipboard in Javascript

I'm trying to implement a copy link with a thumbnail image like in VidYard,

I've implimented the exCommand and this is my code:

      let selection = window.getSelection();
      let container = document.querySelector('.container');

      if (selection.rangeCount > 0) {
        selection.removeAllRanges();
      }
      
      const range = document.createRange();
      range.selectNode(container);
      selection.addRange(range);
      document.execCommand("copy");
      selection.removeAllRanges();

But when I paste in Gmail I can't display the link since it's in a hidden span:

      <span className="classClipboard">
        <img
          src="image/path"
          className="className"
        />
        <span style={{ opacity: 0 }}>{"MyLink"}</span>
      </span>

Any ideas to fix this?

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!