【发布时间】:2016-09-02 11:56:09
【问题描述】:
是否可以使用 jQuery 中的 text 属性来选择按钮?
我想:
$.each(data, function(index, element){
if(element.table_aval == 0)
{
var elmt = element.table_no;
$('#table button[text='+elmt+']').css('color','red');
}
});
这可能吗?
【问题讨论】:
-
试试
:contains选择器。 -
$('#table button:contains('+elmt+')').css('color', 'red');像这样???
-
是的。另外,使用 CSS 类比使用内联 CSS 更好。
-
但它不起作用..
-
数据是通过ajax获取的数组,即表行