JavaScript QRcode create

JavaScript
              
// QR code Create
const txtContent = document.getElementById("txtContent");
const qrcodeCreate = document.querySelector(".qrcodeCreate");
qrcodeCreate.addEventListener("click", (e) => {
  if (txtContent.value != '' ) {
    const qrView = document.querySelector(".qrcodeView");
    if(qrView.firstChild) {
      while (qrView.firstChild) {
        qrView.removeChild(qrView.firstChild);
      }
    }
    new QRCode(document.querySelector(".qrcodeView"), txtContent.value);

    document.querySelector(".qrcodeDownload").style.display ="flex";
  }
});

// QR code Download
const qrcodeDownload = document.querySelector(".qrcodeDownload");
qrcodeDownload.addEventListener("click", (e) => {
  const src = document.querySelector('.qrcodeView').children[1].getAttribute('src');
  
  var xhr = new XMLHttpRequest();
  xhr.open('GET', src, true);
  xhr.responseType = 'blob';
  xhr.onload = function(e){
    if(this.status == 200){
      var urlUtil = window.URL || window.webkitURL;
      var imgUrl = urlUtil.createObjectURL(this.response);
      var link = $('', {
        href: imgUrl, download: "qrcode.png", 
      });
      $('body').append(link);
      link[0].click();
      link.remove();
    }
  };
  xhr.send();

});