Anjan Dutta
Generate a QR Code in Javascript
Generate a QR Code in Javascript
Published On: 08/04/2022
To generate a QR code in Javascript, we will use a QR code library (https://github.com/davidshimjs/qrcodejs).
See the example code below below.
<html> <head> <script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js"></script> </head> <body> <div id="qrcode"> </div> <script> let qrcode = new QRCode(document.getElementById('qrcode'), { text: "Hello World", width: 128, height: 128, colorDark: '#000', colorLight: '#fff' }); </script> </body></html>
This way we can generate a QR code in Javascript.