1
我使用Javascript在HTML表格列中搜索。但是,我只能通過輸入表格單元格內容的第一個字母來搜索值。用Jquery部分搜索TABLE中的單詞
我的數據示例如下所示。
如果我在柱2搜索的值,期望的表格單元格像它應該彈出。
如果我搜索的值或例如,沒有任何反應。
|column1|column2|
__________________
|000|123 456|
|001|123 456|
我目前的Javascript:
<script type="text/javascript">
$("#searchn").on("keyup", function() {
var value = $(this).val();
$("table tr").each(function(index) {
if (index !== 0) {
$row = $(this);
var id = $row.find("td").children().eq(1).text();
if (id.indexOf(value) !== 0) {
$row.hide();
}
else {
$row.show();
}
}
});
});
</script>
工程就像一個魅力:)!謝謝你的解釋和明確的例子。 – Leon
沒問題,很高興幫助 –