이것은 최선의 방법은 아니지만 성능에 대해서는 잘 모르겠지만 각 열의 각 열에 열 식별자로 시작하는 ID를 붙인 다음 옵션을 사용하여 레코드 식별자와 같은 고유 번호 당신이 열 이름을 생산했고, 레코드 ID가 763 인 경우
예를 들어, 나는 다음과 같은 것을 할 것 :
<table id="table1">
<thead>
<tr>
<th>Artist</th>
<th>Album</th>
<th>Genre</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td id="artist-127">Red Hot Chili Peppers</td>
<td id="album-195">Californication</td>
<td id="genre-1">Rock</td>
<td id="price-195">$8.99</td>
</tr>
<tr>
<td id="artist-59">Santana</td>
<td id="album-198">Santana Live</td>
<td id="genre-1">Rock</td>
<td id="price-198">$8.99</td>
</tr>
<tr>
<td id="artist-120">Pink Floyd</td>
<td id="album-183">Dark Side Of The Moon</td>
<td id="genre-1">Rock</td>
<td id="price-183">$8.99</td>
</tr>
</tbody>
</table>
그런 다음 사용할 수있는 jQuery를하는의 시작을 기준으로 필터링하기 id
. 당신이 아티스트의 열을 기준으로 필터링하려는 경우 예를 들어
는 : 포함 ('텍스트')과 : 여기
var regex = /Hot/;
$('#table1').find('tbody').find('[id^=artist]').each(function() {
if (!regex.test(this.innerHTML)) {
this.parentNode.style.backgroundColor = '#ff0000';
}
});
이것은 매우 효율적인 방법이지만, 무엇보다도 작은 코드가 있습니다. P 감사합니다. – Jimbo
http : //jsfiddle.net/urf6P/1073/... 작동하지 않습니다. 나를 위해 – Si8
아주 좋은 솔루션! – Alphacoder