Js 之生成二维码插件(jquery.qrcode.js)

一、下载

链接:https://pan.baidu.com/s/1cMjaCYQ_buZNT5XRRjuNTA
提取码:myqm 

二、效果图

 三、代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #qrcode {
            width:160px;
            height:160px;
            margin-top:15px;
        }
    </style>
</head>
<body>
<input id="text" type="text" value="http://www.test.com" /><br />
<div id="qrcode"></div>
<script src="./jquery.js"></script>
<script src="./jquery.qrcode.min.js"></script>
<script>

    function makeCode () {
        var elText = document.getElementById("text");

        if (!elText.value) {
            alert("Input a text");
            elText.focus();
            return;
        }
        $("#qrcode").qrcode(elText.value);
    }

    makeCode();

    $("#text").
    on("blur", function () {
        makeCode();
    }).
    on("keydown", function (e) {
        if (e.keyCode == 13) {
            makeCode();
        }
    });
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/yang-2018/p/11678064.html