我试图找到一个忽略重音的字符串,所以在我的例子中,如果我搜索avião或aviao我总是得到两个结果。这是一个启动...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://jquery.com/src/jquery-latest.js"></script>
<script type="text/javascript">
$(function () {
$('input').keyup(function (event) {
if (jQuery.trim($('input').val()) == "") {
return;
}
var str = jQuery.trim($('input').val()).split(" ");
jQuery.each($('table > tbody > tr > td:last-child'), function () {
var colval = $(this).html().toLowerCase();
jQuery.each(str, function () {
var term = this.toLowerCase();
if (colval.indexOf(term) != -1) {
alert(colval);
}
});
});
});
});
</script>
</head>
<body>
<input type="text" id="q" />
<div>
<table>
<thead>
<tr>
<th>Id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>avião resume</td>
</tr>
<tr>
<td>2</td>
<td>résumé</td>
</tr>
<tr>
<td>3</td>
<td>resume</td>
</tr>
<tr>
<td>4</td>
<td>aviao résumé</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>