获取复选框的ID [英] Get checkbox's ID

查看:248
本文介绍了获取复选框的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取<tbody>部分中表中复选框的ID.我有一个live(click)函数,我想根据复选框中的ID弹出一个带有我想要的数据的弹出窗口.

I need to get the ID of checkboxes in a table in the <tbody> section. I have a live(click) function that I want to bring up a popup with the data that i want based in the id in the checkbox.

我还希望允许系统选中多个复选框,我希望能够将id存储在temp var中,并根据需要使用它们,并在我遍历它们时将其清除.

I want to also allow the system, to have multiple checkboxes checked I want to be able to store the ids in a temp var and the use them as needed and get rid of them as I go though them.

推荐答案

只需获取.attr的ID:

$("#container input:checkbox").attr("id")

要获取复选框ID的数组,可以使用.map函数:

To get an array of checkboxes ids you might use .map function:

var idArr = $("#container input:checkbox").map(function(i, el) { return $(el).attr("id"); }).get();

这篇关于获取复选框的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆