我按照这个例子:http ://www.datatables.net/development/filtering
但它不起作用。如果您输入“a”作为搜索键盘,所有行仍会显示在表中,因为它会搜索 html 标记<a>
。我错过了什么?
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script>
$.fn.dataTableExt.ofnSearch['string'] = function ( sData )
{
return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
};
$(document).ready
(
function()
{
$('#search').dataTable
(
{
aoColumns:[
{'sType': 'string'}
]
}
);
}
);
</script>
</head>
<body>
<table id="search">
<thead>
<tr>
<th>search</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="www.google.com">b</a></td>
</tr>
<tr>
<td><a href="www.google.com">c</a></td>
</tr>
<tr>
<td><a href="www.google.com">d</a></td>
</tr>
<tr>
<td><a href="www.google.com">e</a></td>
</tr>
<tr>
<td><a href="www.google.com">f</a></td>
</tr>
<tr>
<td><a href="www.google.com">g</a></td>
</tr>
</tbody>
</table>
</body>
</html>