0
jQuery를 사용하여 테이블에 라이브 검색 기능이 있습니다. 그것은 정말 잘 작동하지만 대소 문자를 구분하지 않으므로 jim
은 Jim
과 같지 않습니다.jQuery를 사용하여 테이블에서 대소 문자를 구분하는 라이브 검색
데모 : 당신은 그냥 두 문자열을 소문자 수http://jsfiddle.net/qxks62x9/
$("#search").on("keyup", function() {
var value = $(this).val();
$("table tr").each(function(index) {
if (index !== 0) {
$row = $(this);
var id = $.map($row.find('td'), function(element) {
return $(element).text()
}).join(' ');
\t \t \t \t \t \t
if (id.indexOf(value) <0) {
$row.hide();
}
else {
$row.show();
}
}
});
});
table, tr, td, th{
border: 1px solid blue;
padding: 2px;
}
table th{
background-color: #999999;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr><th>Forename</th><th>Surname</th><th>Extension</th></tr>
<tr><td>Jim</td><td>Carey</td><td>1945</td></tr>
<tr><td>Michael</td><td>Johnson</td><td>1946</td></tr>
</table>
<br />
<input type="text" id="search" placeholder=" live search"></input>
그것은 ** 대소 문자를 구분 **입니다. 그것을 원하지 않니? – sed
아니요, 나는 그렇게하고 싶지 않습니다. 나는'jim'과'Jim' 둘 다 입력 할 수 있기를 원합니다 :-) – michaelmcgurk