自动关注jQuery DataTable的搜索框 [英] Auto focus on search box of jQuery DataTable
本文介绍了自动关注jQuery DataTable的搜索框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到在页面加载时自动关注jQuery Datatable的Search Box的方法.
I am unable to find a way to auto focus on jQuery Datatable's Search Box on page load.
这里的问题是此文本框未提供ID,因此我无法访问它.
The problem here is that this Text box is not given a ID and so i'm unable to access it.
有人可以帮我解决这个问题.
Can someone help me with this issue.
Datatable的示例位于 https://datatables.net/examples/advanced_init/html5-data-options.html
An example of Datatable is at https://datatables.net/examples/advanced_init/html5-data-options.html
谢谢!
推荐答案
您可以使用jquery进行此操作:
You can do this with jquery:
$(function() {
$('#datatabelID [type="search"]').focus()
});
或
$('div.dataTables_filter input').focus()
只需将数据表ID与上述选择器一起使用,您就可以访问搜索文本框.
Just use your datatable Id with the above selector, and you are bale to access the search textbox.
这篇关于自动关注jQuery DataTable的搜索框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文