https://jsfiddle.net/tad564ys/28/
var donotcountBye = true;
var ByeWeek = function() {
var result = "";
if(donotcountBye) {
result = result + "td.new+td:contains('Bye')";
}
return result;
}
$(ByeWeek()).css('background', 'green');
使用td.new + td
时,如何对td.new执行某些操作HTML
<table>
<tr><td class="new">TEXT</td><td>Bye</td></tr>
</table>
答案 0 :(得分:1)
由于ByeWeek
是一个函数,您需要使用括号()
调用它:
$(ByeWeek()).css('background', 'green');
FIDDLE:https://jsfiddle.net/lmgonzalves/tad564ys/22/
修改强>
您可以使用.prev()
,如下所示:
$(ByeWeek()).prev().css('background', 'green');