简体   繁体   English

jQuery DataTables - 删除标签

[英]jQuery DataTables - Remove Label

I'm trying to remove the words "Search:" from the filter label in DataTables. 我正在尝试从DataTables中的过滤器标签中删除“搜索:”字样。 I have tried to use jQuery to replace the label dom but when replaced the filter will not work. 我曾尝试使用jQuery替换标签dom,但更换时过滤器将无法正常工作。 Any one have any other solutions? 任何人都有其他解决方案吗?

Well seems everybody wants code: 好吧似乎每个人都想要代码:

<div id="table-staff_wrapper" class="dataTables_wrapper">
<div id="table-staff_length" class="dataTables_length">
<div id="table-staff_filter" class="dataTables_filter">
<label>
Search:
<input type="text">
</label>
</div>
<table id="table-staff" cellspacing="0" cellpadding="0">
<div id="table-staff_info" class="dataTables_info">Showing 1 to 3 of 3 entries</div>
<div id="table-staff_paginate" class="dataTables_paginate paging_full_numbers">

the above is auto generated by DataTables 以上内容由DataTables自动生成

refer this link http://datatables.net/ref#sinfo 请参阅此链接http://datatables.net/ref#sinfo

add this thing to your code-- 将此内容添加到您的代码中 -

"oLanguage": { "sSearch": "" } 

even if you don't get what you wished then you can simply post the same question on dataTable forum ...dataload team will assist you... 即使你没有得到你想要的东西,你也可以在dataTable论坛上发布相同的问题...... dataload团队会帮助你......

Hope it will help you.. 希望它能帮到你..

You must initialize datatables like this: 您必须像这样初始化数据表:

$('#yourtable').dataTable({
//your normal options

  "oLanguage": { "sSearch": "" } 

});

For datatables 1.10.10 (& possibly above), you can use following configuration while creating the datatables instance: 对于数据表1.10.10(以及可能的上面),您可以在创建datatables实例时使用以下配置:

$('.datatable').DataTable({
// other initialization configurations...
// ...
    "language": {
        "search": "_INPUT_",
        "searchPlaceholder": "Search..."
    }
});

For more details, here is the link from DataTables site: https://datatables.net/reference/option/language.searchPlaceholder 有关更多详细信息,请参阅DataTables站点的链接: https//datatables.net/reference/option/language.searchPlaceholder

For Datatables 1.9.4 and above you can use this 对于Datatables 1.9.4及更高版本,您可以使用它

$('#yourtable').dataTable({
//your normal options

  "language": { "search": "" } 

});

Put placeholder when you remove search label 删除搜索标签时放置占位符

$("#data-table").DataTable({
   language: { search: "",searchPlaceholder: "Search..." }
});

For some reason Placeholder wasn't working for me. 由于某种原因占位符不适合我。 So, My workaround for removing Label and Putting place holder is, 那么,我删除Label和Putting place holder的方法是,

$('#RecentLogs').dataTable({
      "oLanguage": { "sSearch": "" }
});

So, above code will remove search label. 因此,上面的代码将删除搜索标签。 And for placeholder. 对于占位符。

$('.dataTables_filter input').attr("placeholder", "Search Here");

Note :- Be sure that you are including placehoder's jquery line after datatable's initialization and after loading external js of datatable. 注意 : - 确保在数据表初始化之后和加载数据表的外部js之后包括placehoder的jquery行。

try below code: 尝试以下代码:

jQuery("level").html("") or 
jQuery("level").text("") or 
jQuery("level").get(0).text("") 

this will get all the level tag element, 这将获得所有级别标记元素,

since there is only on ehere use index 0. 因为只有ehere使用索引0。

It will find level element and set the value as "" 它将找到level元素并将值设置为“”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM