【发布时间】:2020-11-27 02:20:33
【问题描述】:
[This is my datatable.][1]
- 此输入框是一个搜索框。当您在其中输入文本时,搜索处理在 实时,但我想在按下回车键或丢失时进行搜索 重点 。有什么解决办法吗?
【问题讨论】:
标签: javascript jquery web datatable
[This is my datatable.][1]
【问题讨论】:
标签: javascript jquery web datatable
$('#user_table thead tr').clone(true).appendTo( '#user_table thead' );
$('#user_table thead tr:eq(1) th').each( function (i) {
var title = $(this).text();
var id = $(this).attr('id');
//var id = $(this).attr('name');
$(this).html( '<input type="text" id="' + id + '_search"placeholder="'+title+'" />' );
//$(this).html( '<input type="text" name="' + name + '_search"placeholder="Search '+title+'" />' );
$( 'input', this ).on( 'keyup change clear', function (e) {
if(e.which == 13) {
if ( table.column(i).search() !== this.value ) {
table
.column(i)
.search( this.value )
.draw();
}
}
});
});
这是这个问题的完美答案。 我发现了这一点。
【讨论】: