美文网首页
jQuery复选框选中获取值

jQuery复选框选中获取值

作者: 美淼的心动 | 来源:发表于2018-11-05 18:14 被阅读0次

获取选中复选框的内容可以写个value值:

html:

    <input type="checkbox" class="quan" value="1">

        <p>永久有效</p>

    </div>

        <input type="checkbox" class="quan" value="2">

    <p>日期范围</p>

js:

for (let i = 0; i < $(".quan").length; i++) {

    if ($(".quan").eq(i).is(":checked")) {

        console.log($(".quan").eq(i).val())

    }

}

相关文章

网友评论

      本文标题:jQuery复选框选中获取值

      本文链接:https://www.haomeiwen.com/subject/xpxexqtx.html