我已經使用數據表來顯示數據庫表記錄。在這裏我必須突出顯示搜索字符串。我谷歌,並找到以下鏈接。突出顯示數據表搜索字符串
jQuery plugin DataTables: How to highlight the current search text?
在我的情況下,它不能正常工作。可能是因爲我使用ajax方法來加載數據。
"sAjaxSource": "test.php"
請讓我知道,如何實現這一點。由於
我已經使用數據表來顯示數據庫表記錄。在這裏我必須突出顯示搜索字符串。我谷歌,並找到以下鏈接。突出顯示數據表搜索字符串
jQuery plugin DataTables: How to highlight the current search text?
在我的情況下,它不能正常工作。可能是因爲我使用ajax方法來加載數據。
"sAjaxSource": "test.php"
請讓我知道,如何實現這一點。由於
我已經嘗試的亮點jQuery插件動態內容並能正常工作:http://goo.gl/kezH0o
所以我需要你的問題的更多信息,以幫助您
HTML(一些代碼,也許?):
<div id="results"><h1>Search for: Lorem ipsum, it will be highligted.</h1>
<ul>
<li>One Lorem ipsum</li>
<li>Two Lorem ipsum Lorem ipsum</li>
<li>Just Lorem</li>
<li>None of it</li>
</ul>
</div>
CSS:
.highlight { background-color: yellow }
的javascript:
var search = "Lorem ipsum";
$.ajax({
url: '/echo/html/',
data: {
search: search,
delay: 1
},
type: "POST",
dataType: "html"
}).done(function() {
$('#results ul').highlight(search);
});
我使用https://datatables.net/release-datatables/examples/data_sources/server_side.html方法 –
**現在有一個新的插件來處理搜索高亮數據表:[datatables.mark.js(https://github.com/julmot/datatables.mark.js)** – dude