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

174
Views
copy the inner html of a dynamically generated div

I want to take the innerhtml of a dynamically created div and put it in the clipboard but I keep getting a Type error. i want to access the .shortened div but I cant do it and I need help

const results = document.createElement('div')
// call api
function result(url){
    fetch(https://api.shrtco.de/v2/shorten?url=${url})
    .then(res => res.json())
    .then(data =>{
        if (data.ok){
        var data= data
        results.innerHTML = <div class="result">
        <div class="sent">${data.result.original_link}</div>
        <div class="shortened" id="short"><div>${data.result.short_link}</div>
        <div class="copy-wrapper"></div><a href="#" class="copy" onClick= "copyLink()">Copy</a></div>
        </div>
        // create div 
        answer.appendChild(results)
    }else {
        alert('incorrect url')

    }
    mainBtn.innerHTML = "Shorten it!"
 
    })
    
   
 }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Why need to access the innerHTML, when you can put the shortened URL directly to the copyLink function parameter?

<div class="copy-wrapper">
    <a href="#" class="copy" onClick="copyLink('${data.result.short_link}')">Copy</a>
</div>
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!