0
此列表不是過濾器,在過濾器執行前後獲得相同的長度。 txt
和val
值是正確的。使用jQuery過濾錶行列表
$("#filter").on('keyup', function(e){
var val = this.value.toLowerCase();
c.log('trs', $trs.length);
$trs.filter(function(i){
var $el = $(this).find('td:nth-child(2) a')
, txt = $el.text().toLowerCase();
//c.log('test', txt, val);
return !!txt.indexOf(val);
});
c.log('trs', $trs.length);
});
下面是HTML:
<tr>
<td class="numeric"><a id="btc" class="rank">1</a></td>
<td>
<img src="img/Bitcoin.png" class="currency-logo">
<a href="http://www.bitcoin.org" target="_blank">Bitcoin</a>
</td>
</tr>
<tr>
<td class="numeric"><a id="ltc" class="rank">2</a></td>
<td>
<img src="img/Litecoin.png" class="currency-logo">
<a href="http://litecoin.org" target="_blank">Litecoin</a>
</td>
</tr>
在TD使用的.html()不.VAL()。嘗試alert(val)//我不認爲它會重新獲取任何數據.. –
請發佈相關的html並給出一些更多的解釋。 –
我沒有使用'.val()'。我發佈了html。 – chovy