Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何使用value成员属性查找元素_Jquery_Jquery Ui - Fatal编程技术网

Jquery 如何使用value成员属性查找元素

Jquery 如何使用value成员属性查找元素,jquery,jquery-ui,Jquery,Jquery Ui,我需要在gridview中禁用一行,并使用某些条件使复选框禁用: 例如: if (row["Islicense"].toString() == "false") { // disable the row and checkbox } 此处标识id为“valuemember” 以下是供您参考的HTML: 雇员 恢复于2015年5月4日下午12:43:51完成 资产收回于2015年5月4日12:43:51 pmdrop收回于2015年5月4日12:43:51 pmaccounting收回

我需要在gridview中禁用一行,并使用某些条件使复选框禁用: 例如:

if (row["Islicense"].toString() == "false") {
   // disable the row and checkbox 
}
此处标识id为“valuemember”

以下是供您参考的HTML:


雇员
恢复于2015年5月4日下午12:43:51完成
资产收回于2015年5月4日12:43:51 pmdrop收回于2015年5月4日12:43:51 pmaccounting收回于2015年5月4日12:43:51 pmslips收回于2015年5月4日12:43:51 pmtickets收回于2015年5月4日12:43:51 PM
这个怎么样:

 if($('tr[valuemember="0"]').length){}

迭代表行并检测所需的属性,与您的条件进行比较并禁用或不禁用相应的行

在这种情况下,您将禁用valuemember属性等于
yourCriteria

jQuery

$('.grid_table tr').each(function() {
   var that = $(this);
   if (that.attr('valuemember') == 'yourCriteria') {
      that.find('input[type=checkbox]').prop('disabled', true);
      that.addClass('disabledRow');
   }
});
CSS


演示(禁用valuemember==1的行)

$('.grid_table tr')。每个(函数(){
var,该值=$(此值);
如果(that.attr('valuemember')=='1'){
that.find('input[type=checkbox')).prop('disabled',true);
addClass('disabledRow');
}
});
.disabledRow{
不透明度:0.3
}

雇员
恢复于2015年5月4日下午12:43:51完成
资产收回于2015年5月4日12:43:51 pmdrop收回于2015年5月4日12:43:51 pmaccounting收回于2015年5月4日12:43:51 pmslips收回于2015年5月4日12:43:51 pmtickets收回于2015年5月4日12:43:51 PM

仍然存在一个问题。存在行选择事件,因此每当我单击特定行时,我都能够选中复选框,即使复选框的属性为disable=true。因此,任何建议。我为行禁用做了:that.find(“td”).unbind(“click”);对于复选框禁用:that.find('input,checkbox').prop(“disabled”,true);还是不工作
$('.grid_table tr').each(function() {
   var that = $(this);
   if (that.attr('valuemember') == 'yourCriteria') {
      that.find('input[type=checkbox]').prop('disabled', true);
      that.addClass('disabledRow');
   }
});
.disabledRow {
   opacity: 0.3
}