任何人都可以建议我如何更改此JavaScript,以便读取列表<ul>而不是文本文件吗?

我正在处理一个网页列表,该列表在单击时会产生QR码。 QR码根据选择的选项而变化。现在,我们有一个HTML下拉列表,此JS从文本文件读取以自动更新列表并生成QR。我正在尝试将其转换为仅从html中的

  • 标记读取并产生QR输出的JS。这可能吗?有人会对如何执行此操作有任何建议吗? 我不太确定该如何分解,因为我是JS新手      /这适用于下拉列表/

    function updateList(text)
    {
        var arr = text.split("\n")
        for(var i in arr) {
        var option = document.createElement("option");
            var content = arr[i].split("*")
            option.text = content[0];
            console.log(option.text);
            option.value = content[1];
            console.log(option.value);
            var select = document.getElementById("myList");
            select.appendChild(option);
        }
    }
    
    function setPicture()
    {
    
        var dv = document.getElementById('qrcode');
    
    
        // clear previous qr code
        while (dv.hasChildNodes()) { 
            dv.removeChild(dv.lastChild); 
        } 
        var list = document.getElementById('myList');
    
        //point to url and pass to qrGen function
        var link = list.options[list.selectedIndex].value;
        console.log(link);
        qrGen(link);
    
    
    }
    
      
    function openText(file)
    {
    
        var allText = '';
        $("div").append("<option></option>");
        var buffer = new XMLHttpRequest();
        buffer.open("GET",file,false);
        buffer.onreadystatechange = function ()
        {
            if(buffer.status == 200 && buffer.readyState == 4){
            allText = buffer.responseText;
            }    
        }
        buffer.send(null);
        updateList(allText)
    }
    
    function qrGen(link)
    {
    
    {
    new QRCode(document.getElementById("qrcode"),link);
    
    }
    }
    
    
    </script>
    
  • yangpq008 回答:任何人都可以建议我如何更改此JavaScript,以便读取列表<ul>而不是文本文件吗?

    暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
    本文链接:https://www.f2er.com/3063792.html

    大家都在问