【问题标题】:Auto focus on search box of jQuery DataTable自动关注 jQuery DataTable 的搜索框
【发布时间】:2016-08-24 20:24:17
【问题描述】:

我无法找到在页面加载时自动关注 jQuery Datatable 的搜索框的方法。

这里的问题是这个文本框没有给定一个 ID,所以我无法访问它。

谁能帮我解决这个问题。

Datatable 的一个例子是https://datatables.net/examples/advanced_init/html5-data-options.html

谢谢!

【问题讨论】:

    标签: jquery asp.net vb.net


    【解决方案1】:

    你可以用 jquery 做到这一点:

    $(function() {
        $("#datatabelID [type='search']").focus();
    });
    

    $("div.dataTables_filter input").focus();
    

    只需将您的数据表 ID 与上述选择器一起使用,您就可以访问搜索文本框。

    【讨论】:

    • 试试这个:$('div.dataTables_filter input').focus();
    • 酷!更新了我的答案!!如果有帮助,请将其标记为答案@Reddy
    猜你喜欢
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    • 2015-05-21
    • 2013-08-20
    • 1970-01-01
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多