gpt4 book ai didi

javascript - 如何获取复选框提供的所有值

转载 作者:行者123 更新时间:2023-11-28 17:48:26 25 4
gpt4 key购买 nike

如何从提供的复选框中获取所有值?

这是代码:

$(document).on('pjax:complete', function(data){

var checkbox = $("input[type='checkbox'][name='selection[]']");

for (var i = 0; i < checkbox.length; i++) {
console.log(checkbox[i]); // get html string
console.log(checkbox[i].val()); // checkbox[i].val is not a function
}

});

请指教。

最佳答案

您想要所有复选框值吗?试试这个:

$("input[type='checkbox']").serialize()

关于javascript - 如何获取复选框提供的所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46172657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com