Original question: here
Upon searching i need to alter the results across rows which are equal to the search val();
For this example lets assume we need 90042.
Current js:
(function($) {
$(document).ajaxComplete(function(e, xhr, settings) {
var zip = ($("#edit-field-zip-value").val());
$('.zip div').filter(function() {
return $(this).text() == zip;
}).css('color','red');
});
}(jQuery));
Markup:
<table>
<tbody>
<tr>
<td>
<div class="zip">
<div style="color: red">90042</div>
<div>90052</div>
<div>90062</div>
<div>90072</div>
<div>90082</div>
</div>
</td>
<td>
<div class="marker">
<div>foo</div>
</div>
</td>
<td>
<div class="dma">
<div>Pheonix</div>
<div>Flagstaff</div>
<div>Tucson</div>
<div>Lipsum</div>
<div>Goro</div>
</div>
</td>
</tr>
</tbody>
</table>
The end goal here is to remove all div’s other than 90042, foo, and pheonix.
Something like this:
<table>
<tbody>
<tr>
<td>
<div class="zip">
<div style="color: red">90042</div>
</div>
</td>
<td>
<div class="marker">
<div>foo</div>
</div>
</td>
<td>
<div class="dma">
<div>Pheonix</div>
</div>
</td>
</tr>
</tbody>
</table>
I have a feeling the results of my questions will result in un-even rows so it may be necessary to append end results to new divs or table. ( Might be wrong here tho )
So with your answer to @DonZacharias’ comment, you could format the HTML this way
and then the code becomes
otherwise you have to find the index of the div you’re looking for. It ain’t a good idea, but if you insist, this should do it: