使用jquery查找最后一列的值,并根据值选择第一列中的复选框 [英] Using jquery find the value of last column and select the checkbox in first column based on the value

查看:75
本文介绍了使用jquery查找最后一列的值,并根据值选择第一列中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,



i有一个表,第一列名称Assign有复选框,最后一列名称为Assigned to,我需要一个jQuery逻辑要检查每行中的最后一列值,如果该值为空,请在第一列中选​​中复选框。



我尝试过:



$(table [role ='grid'] tr:not(:first))。each(function(){

var valueOfCell = $(this).find('td:last-child')。text();

alert(valueOfCell);



//检查值是否为空

if(valueOfCell ==''){

//我如何获得第一列...

}

});

解决方案

(table [role ='grid'] tr:not (:第一个))。each(function(){

var valueOfCell =


(this).find('td:last-child')。 text();

alert(valueOfCell);



//检查值是否为空

if(valueOfCell ==''){

//我如何获得第一列.. 。

}

});


试试这个



 <  !DOCTYPE     html  >  
< ; html >
< body >
< script src = https://ajax.googleapis.com/ajax/libs /jquery/1.12.4/jquery.min.js\"> < < span class =code-keyword> / script >

< table id = table1 >
< tr > < td > Col1 < / td > < td > Col2 < / td > ; < td > Col3 < / td > < / tr >
< tr > < td > < 输入 type = 复选框 > < / td > < td > Col2 < / td > ; < td > Col3 < / td > < / tr >
< tr > < td > < 输入 类型 = 复选框 > < / td > < td > Col2 < / td > < td > Col3 < / td > < / tr >
< tr > < td > < 输入 类型 = 复选框 > < / td > < td > Col2 < / td > < td > < / td > < / tr >
< span class =code-keyword>< tr > < td > < 输入 type = 复选框 > < / td > < span class =code-keyword>< td > C ol2 < / td > < span class =code-keyword>< td > Col3 < / td > < / tr >
< tr > < td > < 输入 type = 复选框 & gt; < / td > < td > Col2 < / td > < td > Col3 < / td > < / tr >

< / table >
< script > ;

Hi Team,

i have a table, with first column name "Assign" having check box and last column name "Assigned to", i need a jQuery logic to check last column value in each row and if the value is empty make the check box checked in the first column.

What I have tried:

$("table[role='grid'] tr:not(:first)").each(function () {
var valueOfCell = $(this).find('td:last-child').text();
alert(valueOfCell);

//check if the value is empty
if (valueOfCell == ''){
// how do i get the first column ...
}
});

解决方案

("table[role='grid'] tr:not(:first)").each(function () {
var valueOfCell =


(this).find('td:last-child').text();
alert(valueOfCell);

//check if the value is empty
if (valueOfCell == ''){
// how do i get the first column ...
}
});


try this

<!DOCTYPE html>
<html>
<body>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

    <table id="table1">
        <tr><td>Col1</td><td>Col2</td><td>Col3</td> </tr>
        <tr><td><input type="checkbox"></td><td>Col2</td><td>Col3</td> </tr>
        <tr><td><input type="checkbox"></td><td>Col2</td><td>Col3</td> </tr>
        <tr><td><input type="checkbox"></td><td>Col2</td><td></td> </tr>
        <tr><td><input type="checkbox"></td><td>Col2</td><td>Col3</td> </tr>
        <tr><td><input type="checkbox"></td><td>Col2</td><td>Col3</td> </tr>

    </table>     
      <script>


这篇关于使用jquery查找最后一列的值,并根据值选择第一列中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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