Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery plugin DataTables: How to highlight the current search text?

I have started using the DataTables plugin (v1.6.2) for jQuery(v1.4.2), and I would like to ask you if you know a settings or a plugin that allow me to highlight the text used in search textbox on the filtered rows.

Thank you in advance

like image 277
Drake Avatar asked Apr 15 '10 12:04

Drake


1 Answers

I know that this question is now over 6 years old and the answers here may helped you at the time of asking. But for people still searching for this, there is a new plugin to integrate mark.js – a JavaScript keyword highlighter – into DataTables: datatables.mark.js.

Usage is as simple as:

$("table").DataTables({
    mark: true
});

Here is an example: https://jsfiddle.net/julmot/buh9h2r8/

This is the cleanest way and also gives you options none of the given solutions offers you.

There's now an official DataTables blog article available.

like image 157
dude Avatar answered Sep 30 '22 12:09

dude