勾选复选框后点击选择按钮实现弹出框出现你“选中了‘复选框后的文字’”。

问题:勾选复选框后点击选择按钮实现弹出框出现你“选中了‘复选框后的文字’”。
代码:


```html
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./script/jquery-3.6.0.min.js"></script>
 <script>
        $(function(){
            var $inputs = $('input');
            console.log($inputs);
            var $btn = $('$btn');
            var btn = $btn[0];
            btn.onclick =function(){
                
            }
        })
    </script>
</head>
<body>
    <label for="id1">
        <input type="checkbox">王者
    </label>
    <label for="id2">
        <input type="checkbox">NBA
    </label>
    <label for="id3">
        <input type="checkbox">LPL
    </label>
    <label for="id4">
        <input type="checkbox">华为
    </label>
    <label for="id5">
        <input type="checkbox">小米
    </label>
    <label for="id6">
        <input type="checkbox">苹果
    </label>
    <label for="id7">
        <input type="checkbox">vivo
    </label>
    <label for="id8">
        <input type="checkbox">荣耀
    </label>
    <br>
    <button id="btn">选择</button>
</body>



 











<body>
    <label for="lq">篮球</label><input type="checkbox" value="篮球" id="lq">
    <label for="zq">足球</label><input type="checkbox" value="足球" id="zq">
    <label for="yq">羽毛球</label><input type="checkbox" value="羽毛球" id="yq">
    <label for="pq">乒乓球</label><input type="checkbox" value="乒乓球" id="pq">
    <label for="tq">台球</label><input type="checkbox" value="台球" id="tq">
    <button onclick="sav()">选择</button>
</body>

</html>
<script>
    function sav() {
        var cont = ``;
        $inp = $("[type='checkbox']");
        console.log($inp);
        for (var i = 0; i < $inp.length; i++) {
            if ($inp[i].checked == true) {
                cont += $inp[i].value;
            }

        }
        alert(`你的兴趣爱好是:${cont}`)
    }

此方法是获取value值 输出字符串,你也可以保存到数组内输出
方法多种多样