admin管理员组文章数量:1312658
I'm trying to get the id's of the checkboxes with the class file-selection-id
. The checkbox is inside a for loop which is why I have placed variables on the id's and names.
<input class="file-selection-id" type="checkbox" value="" name="file<?php echo $i; ?>_<?php echo $t; ?>" id="file<?php echo $i; ?>_<?php echo $t; ?>">
What I want is that when I click a button, it would get all of the id's of the selected checkboxes.
$('.move-file-buttons').click(
function(event) {
//???
$('input:checkbox.file-selection-id').each(function () {
});
});
But I don't know how to get the Id's of all the checkboxes that were on the file-selection-id class that I need? What could be ways on how I could call the ID's of the checkboxes(for example if I had 4 checkboxes with 2 selections)?
I'm trying to get the id's of the checkboxes with the class file-selection-id
. The checkbox is inside a for loop which is why I have placed variables on the id's and names.
<input class="file-selection-id" type="checkbox" value="" name="file<?php echo $i; ?>_<?php echo $t; ?>" id="file<?php echo $i; ?>_<?php echo $t; ?>">
What I want is that when I click a button, it would get all of the id's of the selected checkboxes.
$('.move-file-buttons').click(
function(event) {
//???
$('input:checkbox.file-selection-id').each(function () {
});
});
But I don't know how to get the Id's of all the checkboxes that were on the file-selection-id class that I need? What could be ways on how I could call the ID's of the checkboxes(for example if I had 4 checkboxes with 2 selections)?
Share Improve this question asked Nov 13, 2013 at 3:00 marchemikemarchemike 3,27713 gold badges60 silver badges99 bronze badges1 Answer
Reset to default 5Use .map
var arr = $('input:checkbox.file-selection-id').map(function () {
return this.id;
}).get();
if you want
id
of checked
check-boxes
var arr = $('input:checkbox.file-selection-id').filter(':checked').map(function () {
return this.id;
}).get();
var arr = $('input:checkbox.file-selection-id:checked').map(function () {
return this.id;
}).get();
.filter()
本文标签: javascriptGetting id of checkboxes selected using jqueryStack Overflow
版权声明:本文标题:javascript - Getting id of checkboxes selected using jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741911128a2404450.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论