jQuery获取checkbox行其他td内input的值
2017-06-28 14:31
471 查看
这两天遇到这么一个需求,需要点击删除时候有个comfirm提示框,提示框内展示要删除的数据。比如点击一堆checkbox后获取该行的input值
大致代码如下
<tr>
<td><input type = "checkbox" name = "p1" id = "p1" value = true><td>
<td><input type = "text" name = "xx" id = "xx" value = "张三"><td>
<td><input type = "text"
name = "yy" id = "yy" value = "李四"><td>
<tr>
<tr>
<td><input type = "checkbox" name = "p1" id = "p1" value = true><td>
<td><input type = "text" name = "xx" id = "xx" value = "王五"><td>
<td><input type = "text"
name = "yy" id = "yy" value = "赵六"><td>
<tr>
代码部分
写在提交按钮中的方法
var arr = [];
$("input:checkbox [name = ??]:checked").each(function(){
arr.push($(this).parents('tr').children().eq(2).html());//eq(2)表示checkbox后的第二个<td>
})
arr.splice(0, arr.length); //每次方法点击后清空数组,防止下次点击事件触发数组内数据未制空
大致代码如下
<tr>
<td><input type = "checkbox" name = "p1" id = "p1" value = true><td>
<td><input type = "text" name = "xx" id = "xx" value = "张三"><td>
<td><input type = "text"
name = "yy" id = "yy" value = "李四"><td>
<tr>
<tr>
<td><input type = "checkbox" name = "p1" id = "p1" value = true><td>
<td><input type = "text" name = "xx" id = "xx" value = "王五"><td>
<td><input type = "text"
name = "yy" id = "yy" value = "赵六"><td>
<tr>
代码部分
写在提交按钮中的方法
var arr = [];
$("input:checkbox [name = ??]:checked").each(function(){
arr.push($(this).parents('tr').children().eq(2).html());//eq(2)表示checkbox后的第二个<td>
})
arr.splice(0, arr.length); //每次方法点击后清空数组,防止下次点击事件触发数组内数据未制空
相关文章推荐
- jQuery根据ID获取input、checkbox、radio、select的示例
- jquery 获取input radio/checkbox 的值 【注意写法】
- jQuery根据ID获取input、checkbox、radio、select的示例
- jQuery获取form中Select/textarea/checkbox/radio选择的Text和Value等其他常见操作
- jquery 处理table 中获取td下input数据
- jquery获取checkbox选中的值并追加到input中
- Jquery实际应用,判断radio,selelct,checkbox是否选中及选中的值,jquery如果获取多个重复name的input的值
- jquery 获取所有checkbox选中input
- jquery获取td中的input
- 【jQuery获取下拉框select、单选框radio、input普通框的值和checkbox选中的个数】
- jquery获取checkbox选中的值并追加到input中
- input-color与input-checkbox元素通过jquery获取值以及设定值(input属性的取值与设定)
- jquery 选择input的checkbox属性 获取checkbox的值 用异步传输数据 返回结果
- jQuery 根据ID,获取input/checkbox/radio/select
- jQuery学习笔记---获取表单值(Input Checkbox ListBox Button...)
- Jquery 获取指定 table下 所有 type='text' 的 input
- JQUERY获取text,areatext,radio,checkbox,select值
- Jquery 获取表单text,areatext,radio,checkbox,select值的代码
- js checkbox全选并将获取值放到input里边
- Jquery 获取指定 table下 所有 type='text' 的 input