【问题标题】:how to delete a checkbox on condition using jquery如何使用jquery删除条件复选框
【发布时间】:2014-01-03 20:08:15
【问题描述】:

我有这样的事情:

<th colspan="2">Status</th>
<th class="data-name">Name</th>
<th class="data-name">Description</th>

状态字段有 2 个值:复选框为“使用中”和“未使用”。我想为复选框添加一个验证,如果状态为“使用中”->不要删除复选框,否则删除。这是一个例子:

 if $('.data-checkbox input[type="checkbox"]:checked').inUse  
 { 
     alert('do not delete the checkbox');
 } 
 else 
 {
     alert('delete the checkbox');
 }

简而言之,如果checkbox被勾选并且条件(如果chckbox not in use得到满足),那么就删除整行...

这里是 html:<th class="data-checkbox"><input type="checkbox" id="data-selectall" /></th> <th colspan="2">Status</th> <th class="data-name">Name</th> <th class="data-name">Description</th>

我只是想达到一个有效的删除条件:

if (checkbox is in use) {(dont delete)}
else {(delete)}

【问题讨论】:

标签: javascript jquery checkbox


【解决方案1】:

if $('.data-checkbox input[type="checkbox"]:checked').inUse

这没有任何意义,如果有的话:

if( $('.data-checkbox input[type="checkbox"]:checked').inUse )

您忘记了if 语句的括号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    • 2014-04-18
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    相关资源
    最近更新 更多