A Pen by Max Programming on CodePen.
Created
June 16, 2023 11:42
-
-
Save MFathurrohmanMauludin/b0419a38f06b3f1e962527848f5ae63d to your computer and use it in GitHub Desktop.
QR Code Generator using JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>QR Code Generator</h1> | |
<input type="text" spellcheck="false" id="text" value="https://google.com" /> | |
<div id="qrcode"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const qrcode = document.getElementById("qrcode"); | |
const textInput = document.getElementById("text"); | |
const qr = new QRCode(qrcode); | |
textInput.oninput = (e) => { | |
qr.makeCode(e.target.value.trim()); | |
}; | |
qr.makeCode(textInput.value.trim()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
width: 80%; | |
height: 100vh; | |
margin: auto; | |
display: grid; | |
place-items: center; | |
} | |
h1 { | |
font-family: sans-serif; | |
} | |
input { | |
padding: 10px; | |
border-radius: 20px; | |
border: 2px solid steelblue; | |
font-size: 1.5rem; | |
letter-spacing: 2px; | |
outline: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment