jamesfzhang
jamesfzhang

Reputation: 4473

Default dataTable search box text

The code below filters the table upon initialization to match "Search for..." This is not useful to me.

$(document).ready(function(){
  $('.table').dataTable({
    "oSearch": {"sSearch": "Search for..."});
});

What I want is for "Search for..." to appear in the search box itself without initializing the search parameters on page load. When the user places focus on the search box, the string disappears and the user can start typing. Any ideas?

Upvotes: 3

Views: 3526

Answers (1)

Jonathan Römer
Jonathan Römer

Reputation: 628

You can give the searchbox an value like "Search for" and use jquery to clear it with onfocus, or blur, which you prefer. To clear the value when somebody "focusses " on the box.

Upvotes: 1

Related Questions