-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (25 loc) · 872 Bytes
/
script.js
File metadata and controls
33 lines (25 loc) · 872 Bytes
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
// Fetching all the elemnts
const contain = document.querySelector(".container"),
qrInput = contain.querySelector(".box input"),
generatebtn = contain.querySelector(" .box button");
img1=contain.querySelector(".code img");
// qr code genertor
generatebtn.addEventListener("click", ()=>{
let qrValue = qrInput.value;
if(!qrValue)return;
// generating qr code
generatebtn.innerText= "Generating QR Code....."
// fetching qr code api
img1.src =`https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${qrValue}`;
// for loading image or qr code
img1.addEventListener("load", () =>{
contain.classList.add("active");
generatebtn.innerText ="Generate QR Code";
})
});
// for removing box or qr code generator
qrInput.addEventListener("keyup", ()=>{
if(!qrInput.value){
contain.classList.remove("active");
}
})