javascript - JQuery : find tr(class = x) get td(class =y) count td variables and attribute, 而不是相应地更改 tr

标签 javascript jquery html css jquery-ui

<table class="tbl">
<tr>td class= "colorcode" colspan ="5"/><tr>
<tr class="ms.alternative>
<td></td>
<td class="bkcolor"></td>
<td class="bkcolor"></td>
<td class="bkcolor"></td>
<td> </td>
</tr>
<tr><td colspan="5"/></tr>


 <tr>td class= "colorcode" colspan ="5"/><tr>
<tr class="ms.alternative>
<td></td>
<td class="bkcolor"></td>
<td class="bkcolor"></td>
<td class="bkcolor"></td>
<td></td>
</tr>
<tr><td colspan="5"/></tr>


<tr>td class= "colorcode" colspan ="5"/><tr>
<tr class="ms.alternative>
<td></td>
<td class="bkcolor"></td>
 <td class="bkcolor"></td>
<td class="bkcolor"></td>
<td></td>
</tr>
<tr><td colspan=""/></tr>

</table>

我是 jquery 的新手..请帮我弄明白。

在上面的场景中:

现在我的问题是:您将如何使用

选择所有 tr
class ms.alternative than find(td.bkcolor)
get the color of <td.bkcolor>

现在,如果:

 (number of majority of background color of '`tr.ms.alternative`' '`td.bkcolor`' 
 is red)
 {
     change td.colorcode.css(background-color:'red')
 }

最佳答案

$('tr[class="ms.alternative"]').find('td[class="bkcolor"]').css("background-color");

将为您提供背景颜色

 $('tr[class="ms.alternative"]').find('td[class="bkcolor"]').css("background-color","new color");

会改变你的背景颜色

关于javascript - JQuery : find tr(class = x) get td(class =y) count td variables and attribute, 而不是相应地更改 tr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22124937/

相关文章:

javascript - QPython3 在 HTML GUI 中使用 Javascript 的问题

jquery - 无法让 addClass 在 Img 上工作

jquery - 如何隐藏/删除基于 Bootstrap 媒体查询断点的类?

javascript - 使用 jQuery 多选将值添加到 url 哈希

html - 您如何在 PLay 中处理 HTML 和 CSS! + 智能理念?

html - 如何在 li 中垂直对齐图像

javascript - 将点击分配给循环函数中的元素

javascript - 我可以将参数类型指定为多种类型之一而不是 TypeScript 中的任何类型吗?

javascript - select with ngOptions 选择另一个数组的过滤器

javascript - 从一行后面显示两个文本元素