Skip to content

Instantly share code, notes, and snippets.

@MFathurrohmanMauludin
Created June 16, 2023 11:42
Show Gist options
  • Save MFathurrohmanMauludin/b0419a38f06b3f1e962527848f5ae63d to your computer and use it in GitHub Desktop.
Save MFathurrohmanMauludin/b0419a38f06b3f1e962527848f5ae63d to your computer and use it in GitHub Desktop.
QR Code Generator using JavaScript
<h1>QR Code Generator</h1>
<input type="text" spellcheck="false" id="text" value="https://google.com" />
<div id="qrcode"></div>
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());
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
* {
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