<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="../js/jquery-3.2.1.min.js"></script>
<script>
$(function () {
//两种写法相同
// $("tr[class='q']").each(function (index, element) {
// $(element).css("color", "green");
// }
$.each($("tr[class='q']"),function (index,element) {
$(element).css("background", "blue");
})
})
</script>
</head>
<body>
<table>
<tr class="q">
<td>1111</td>
<td>22222</td>
</tr>
<tr class="q">
<td>1111</td>
<td>22222</td>
</tr>
<tr class="q">
<td>1111</td>
<td>22222</td>
</tr>
<tr class="q">
<td>1111</td>
<td>22222</td>
</tr>
</table>
<table>
<tr>
<td>1111</td>
<td>22222</td>
</tr>
<tr>
<td>1111</td>
<td>22222</td>
</tr>
<tr>
<td>1111</td>
<td>22222</td>
</tr>
<tr>
<td>1111</td>
<td>22222</td>
</tr>
</table>
</body>
</html>

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-09-26
猜你喜欢
  • 2021-08-19
  • 2021-08-24
  • 2021-06-23
  • 2022-02-09
  • 2021-08-16
  • 2021-12-10
  • 2021-12-10
相关资源
相似解决方案