question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m trying to grab the src of the image generated, however, it only works after the 2nd click.

$("#apply").click( function(){
    var src = qrcode._oDrawing._elImage.currentSrc;
    console.log(src);
});

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

19reactions
lifengboycommented, Aug 2, 2019

try this

const div = document.createElement(‘div’); new QRCode(div, “http://jindo.dev.naver.com/collie”); const src = div.children[0].toDataURL(“image/png”); console.info(‘src’, src);

1reaction
scammicommented, Nov 15, 2018
    new QRCode(qrdiv, links)
    setTimeout(makeLink, 1000)

    function makeLink(){
      var qrlink = document.getElementById("downloadLink")
      var imgsrc = document.getElementsByTagName("img")[0].src
      qrlink.href = imgsrc
      qrlink.innerHTML = "Click here to downloar your QRcode"
      console.log(imgsrc)
    }

I added the timeout, so the src from the qrcode has enough time to load in order to be copied. 

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery get the image src - Stack Overflow
I hope when I click the button, I can get the specific img src and show the img src in the div class...
Read more >
How to get the value of src attribute in jQuery? - Tutorialspoint
To get the value of src attribute in jQuery is quite easy. We will get the src attribute of the img tag. This...
Read more >
HTML img src Attribute - W3Schools
The required src attribute specifies the URL of the image. ... If you do not get permission to use it, you may be...
Read more >
JQuery Get and Set Image Src Example Tutorial - NiceSnippets
We will show easy example of jquery get and set image src.The attr() method to get and change the image source in jQuery....
Read more >
A 4-Minute Guide to the Img src Attribute in HTML
Learn how to use and troubleshoot any issues with the img src attribute in HTML.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found