[英]Multiple ID's in Javascript function
我有多個具有不同ID標記的數據表,並且如果存在多個ID,我正在嘗試獲取JavaScript文件以應用樣式。
這是我不工作的東西:
$(function() {
$("[id*=tblAccount") || ("[id *= tblCustomer") || ("[id *= tblContact").prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false,
"dom": 'lBfrtip',
"buttons": ['excel', 'print', 'pdfHtml5']
});
})
您需要使用CSS選擇器,
運算符在一次對jQuery的調用中組合選擇器:
$("[id*=tblAccount], [id *= tblCustomer], [id *= tblContact]").prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
(還要注意,我添加了缺少的]
字符。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.