-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (35 loc) · 1.07 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QR Code Generator Using HTML CSS And Javascript</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<p>Enter your text or URL</p>
<input type="text" placeholder="Text or URL" id="qrText">
<div id="imgBox">
<img src="" id="qrImage">
</div>
<button onclick="generateQR()">Generate QR Code</button>
</div>
<script>
let imgBox = document.getElementById("imgBox");
let qrImage = document.getElementById("qrImage");
let qrText = document.getElementById("qrText");
function generateQR(){
if(qrText.value.length > 0){
qrImage.src = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + qrText.value;
imgBox.classList.add("show-img");
}else{
qrText.classList.add('error');
setTimeout(()=>{
qrText.classList.remove('error');
},1000);
}
}
</script>
</body>
</html>