return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - Getting id of checkboxes selected using jquery - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting id of checkboxes selected using jquery - Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

Use .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()

发布评论

评论列表(0)

  1. 暂无评论