Reputation: 43
I want to set value of "Search Text Box" empty in datatable with the help of jquery .val() but it is not setting. How can i set value of text box empty in onClick function.
Upvotes: 1
Views: 9035
Reputation: 1976
When you set data input Then call it function For Example: i want search somthing like this => get data in input and search in datatable when put data in searcher datatable in code call it function with keyup()
<table id="user_data">
<input id="day" onchange="onSelectDay(this.value)" placeholder="get_data_from_user_and_put_in_searcher_datatable "/>
</table>
<script>
function onSelectDay(str)
var date = document.getElementById("day").value;
$("input[aria-controls=user_data]").val(date).keyup(); //this input create auto in datatable
</script>
Upvotes: 0
Reputation: 4238
Same idea as above
$('#table-search-clear-filter').on('click', function() {
$('#table-search').val('');
});
And to respond to above comment an id for a dataTable is made as your-datatable-name_filter
Upvotes: 0
Reputation: 4253
You need to trigger keyUp
event; like so:
$('input[type="search"]').val('').keyup()
The listener function that filters data table is binded to keyup event.
Upvotes: 12