Javascript jQuery 数据表 - 删除标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8252841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery DataTables - Remove Label
提问by d123
I'm trying to remove the words "Search:" from the filter label in DataTables. I have tried to use jQuery to replace the label dom but when replaced the filter will not work. Any one have any other solutions?
我正在尝试从 DataTables 的过滤器标签中删除“搜索:”字样。我曾尝试使用 jQuery 来替换标签 dom,但替换后过滤器将不起作用。有人有其他解决方案吗?
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自动生成的
回答by Vivek
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..
希望能帮到你。。
回答by Nicola Peluchetti
You must initialize datatables like this:
您必须像这样初始化数据表:
$('#yourtable').dataTable({
//your normal options
"oLanguage": { "sSearch": "" }
});
回答by Nikhil
For datatables 1.10.10 (& possibly above), you can use following configuration while creating the datatables instance:
对于数据表 1.10.10(以及可能更高版本),您可以在创建数据表实例时使用以下配置:
$('.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
回答by techvineet
For Datatables 1.9.4 and above you can use this
对于 Datatables 1.9.4 及更高版本,您可以使用它
$('#yourtable').dataTable({
//your normal options
"language": { "search": "" }
});
回答by HIR
Put placeholder when you remove search label
删除搜索标签时放置占位符
$("#data-table").DataTable({
language: { search: "",searchPlaceholder: "Search..." }
});
回答by Bhavin
For some reason Placeholder wasn't working for me. So, My workaround for removing Label and Putting place holder is,
出于某种原因,占位符对我不起作用。所以,我删除标签和放置占位符的解决方法是,
$('#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 行。
回答by dku.rajkumar
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.
因为这里只有使用索引 0。
It will find level element and set the value as ""
它将找到级别元素并将值设置为“”