gpt4 book ai didi

javascript - 如何在显示月份数据时删除特定日期列?

转载 作者:行者123 更新时间:2023-11-28 02:26:35 24 4
gpt4 key购买 nike

我写了一个 js 代码来删除第 31 个日期列。

$(document).ready(function() {
$("#search").click(function() {
var e = document.getElementById("selMonth");
var monthSelect = e.options[e.selectedIndex].value;
var tid = null;

if(
$(this).value() == '4'||
$(this).value() == '6'||
$(this).value() == '9'||
$(this).value() == '11'
) {
$('#Production_monitor thead tr td').each(function (event) {
tid = $(this).attr('id');

if($(this).text() == '31'){
$('#' + tid).remove();
}
});
}

if($(this).value() == '2') {
$('#Production_monitor thead tr td').each(function (event) {
tid = $(this).attr('id');

if($(this).text() == '31'){
$('#' + tid).remove();
}

if($(this).text() == '30'){
$('#' + tid).remove();
}
});
}

prodmonitor(monthSelect);
});
});

html代码如下。每当我需要显示 4 月、6 月、9 月、11 月的数据以及删除 2 月的第 31 和 30 列时,我想动态删除第 31 个日期列。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="images/favicon.ico" type="image/ico" />

<title>HMSI</title>

<!-- Bootstrap -->
<link href="vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="vendors/nprogress/nprogress.css" rel="stylesheet">
<!-- iCheck -->
<link href="vendors/iCheck/skins/flat/green.css" rel="stylesheet">

<!-- bootstrap-progressbar -->
<link href="vendors/bootstrap-progressbar/css/
bootstrap-progressbar-3.3.4.min.css" rel="stylesheet">
<!-- JQVMap -->
<link href="vendors/jqvmap/dist/jqvmap.min.css" rel="stylesheet"/>
<!-- bootstrap-daterangepicker -->
<link href="vendors/bootstrap-daterangepicker/daterangepicker.css"
rel="stylesheet">

<!-- Datatables -->
<link href="vendors/datatables.net-bs/css/dataTables.bootstrap.min.css"
rel="stylesheet">
<link href="vendors/datatables.net-bs/css/editor.dataTables.min.css"
rel="stylesheet">
<link href="vendors/datatables.net-buttons-bs/css/buttons.bootstrap.min.css"
rel="stylesheet">
<link href="vendors/datatables.net-fixedheader-
bs/css/fixedHeader.bootstrap.min.css" rel="stylesheet">
<link href="vendors/datatables.net-responsive-
bs/css/responsive.bootstrap.min.css" rel="stylesheet">
<link href="vendors/datatables.net-scroller-
bs/css/scroller.bootstrap.min.css" rel="stylesheet">


<!-- Custom Theme Style -->
<link href="css/custom.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>

<body class="nav-md">
<div class="container body">
<div class="main_container">
<div class="col-md-3 left_col">
<div class="left_col scroll-view">
<div class="navbar nav_title" style="border: 0;">
<a href="index.jsp" class="site_title"><i class="fa fa-motorcycle">
</i> <span>HMSI</span></a>
</div>

<div class="clearfix"></div>

<!-- menu profile quick info -->
<div class="profile clearfix">
<div class="profile_pic">
<img src="images/img.jpg" alt="..."
class="img-circle profile_img">
</div>
<div class="profile_info">
<span>Welcome,</span>
<h2>Admin</h2>
</div>
</div>
<!-- /menu profile quick info -->

<br />

<!-- sidebar menu -->
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
<div class="menu_section">
<h3>General</h3>
<ul class="nav side-menu">
<li><a><i class="fa fa-home"></i> Home <span class=
"fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="Dashboard.jsp">Dashboard</a></li>
</ul>
</li>
<li><a><i class="fa fa-user"></i> Associate <span class=
"fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="Employee.jsp">All Employee</a></li>
<li><a href="Attendance.jsp">Attendance</a></li>
<li><a href="OT.jsp">OT</a></li>
<li><a href="Fingerprint.jsp">Finger Print</a></li>
</ul>
</li>
<li><a><i class="fa fa-edit"></i> Parameter </a>
</li>

<li><a><i class="fa fa-bar-chart-o"></i>Reports<span class=
"fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a>Man Power<span class="fa fa-chevron-down"></span>
</a>
<ul class="nav child_menu">
<li class="sub_menu">
<a href="Attendance.jsp">Attendance</a>
</li>
<li><a href="OT_Monitor.jsp">OT Monitoring Sheet</a>
</li>
<li><a href="Leave_Plan.jsp">Leave plan</a>
</li>
<li><a href="Training_Plan.jsp">Training plan</a>
</li>
</ul>
</li>
<li><a>Quality<span class="fa fa-chevron-down"></span>
</a>
<ul class="nav child_menu">
<li class="sub_menu"><a href="gdptrends.jsp">
GDP Trends</a>
</li>
<li><a href="dpv_vs_actual.jsp">
DPV Targets vs Actual</a>
</li>
<li><a href="pdiclaim.jsp">PDI Monitoring Sheet</a>
</li>
</ul>
</li>
<li><a>Safety<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li class="sub_menu">
<a href="Safety_Calender.jsp">Safety Calender</a>
</li>
<li><a href="Safety_Message.jsp">Safety Message</a>
</li>
<li><a href="audit_check.jsp">5s Check Sheet</a>
</li>
<li><a href="risk_assesment.jsp">Risk Management</a>
</li>
</ul>
</li>
<li><a>Delivery<span class="fa fa-chevron-down"></span>
</a>
<ul class="nav child_menu">
<li class="sub_menu">
<a href="prod_monitor.jsp">Production Monitoring Sheet</a>
</li>
<li><a href="logistic_vs_pdi.jsp">
Login vs PDI OFF Monitoring Sheet</a>
</li>
<li><a href="breakdown.jsp">Break Down Monitoring</a>
</li>
<li><a href="holdstatus.jsp">Hold Vechicle</a>
</li>
</ul>
</li>

</ul>
</li>
<li><a><i class="fa fa-clone"></i>Layouts
<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="fixed_sidebar.html">Fixed Sidebar</a></li>
<li><a href="fixed_footer.html">Fixed Footer</a></li>
</ul>
</li>
</ul>
</div>
<div class="menu_section">
<h3>Live On</h3>
<ul class="nav side-menu">
<li><a><i class="fa fa-bug"></i> Additional Pages
<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="e_commerce.html">E-commerce</a></li>
<li><a href="projects.html">Projects</a></li>
<li><a href="project_detail.html">Project Detail</a></li>
<li><a href="contacts.html">Contacts</a></li>
<li><a href="profile.html">Profile</a></li>
</ul>
</li>
<li><a><i class="fa fa-windows"></i> Extras
<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="page_403.html">403 Error</a></li>
<li><a href="page_404.html">404 Error</a></li>
<li><a href="page_500.html">500 Error</a></li>
<li><a href="plain_page.html">Plain Page</a></li>
<li><a href="login.html">Login Page</a></li>
<li><a href="pricing_tables.html">Pricing Tables</a></li>
</ul>
</li>
<li><a><i class="fa fa-sitemap"></i> Multilevel Menu
<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="#level1_1">Level One</a>
<li><a>Level One<span class="fa fa-chevron-down"></span>
</a>
<ul class="nav child_menu">
<li class="sub_menu"><a href="level2.html">
Level Two</a>
</li>
<li><a href="#level2_1">Level Two</a>
</li>
<li><a href="#level2_2">Level Two</a>
</li>
</ul>
</li>
<li><a href="#level1_2">Level One</a>
</li>
</ul>
</li>
<li><a href="javascript:void(0)"><i class="fa fa-laptop"></i>
Landing Page <span class="label label-success pull-right">
Coming Soon</span></a></li>
</ul>
</div>

</div>
<!-- /sidebar menu -->

<!-- /menu footer buttons -->
<div class="sidebar-footer hidden-small">
<a data-toggle="tooltip" data-placement="top" title="Settings">
<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
</a>
<a data-toggle="tooltip" data-placement="top" title="FullScreen">
<span class="glyphicon glyphicon-fullscreen" aria-hidden="true">
</span>
</a>
<a data-toggle="tooltip" data-placement="top" title="Lock">
<span class="glyphicon glyphicon-eye-close" aria-hidden="true">
</span>
</a>
<a data-toggle="tooltip" data-placement="top"
title="Logout" href="login.html">
<span class="glyphicon glyphicon-off" aria-hidden="true"></span>
</a>
</div>
<!-- /menu footer buttons -->
</div>
</div>

<!-- top navigation -->
<div class="top_nav">
<div class="nav_menu">
<nav>
<div class="nav toggle">
<a id="menu_toggle"><i class="fa fa-bars"></i></a>
</div>

<ul class="nav navbar-nav navbar-right">
<li class="">
<a href="javascript:;" class="user-profile dropdown-toggle"
data-toggle="dropdown" aria-expanded="false">
<img src="images/img.jpg" alt="">Admin
<span class=" fa fa-angle-down"></span>
</a>
<ul class="dropdown-menu dropdown-usermenu pull-right">
<li><a href="javascript:;"> Profile</a></li>
<li>
<a href="javascript:;">
<span class="badge bg-red pull-right">50%</span>
<span>Settings</span>
</a>
</li>
<li><a href="javascript:;">Help</a></li>
<li><a href="login.html">
<i class="fa fa-sign-out pull-right"></i> Log Out</a></li>
</ul>
</li>

<li role="presentation" class="dropdown">
<a href="javascript:;" class="dropdown-toggle info-number"
data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-envelope-o"></i>
<span class="badge bg-green">6</span>
</a>
<ul id="menu1" class="dropdown-menu list-unstyled msg_list"
role="menu">
<li>
<a>
<span class="image"><img src="images/img.jpg"
alt="Profile Image" /></span>
<span>
<span>John Smith</span>
<span class="time">3 mins ago</span>
</span>
<span class="message">
Film festivals used to be do-or-die moments for movie
makers. They were where...
</span>
</a>
</li>
<li>
<a>
<span class="image"><img src="images/img.jpg"
alt="Profile Image" /></span>
<span>
<span>John Smith</span>
<span class="time">3 mins ago</span>
</span>
<span class="message">
Film festivals used to be do-or-die moments for movie
makers. They were where...
</span>
</a>
</li>
<li>
<a>
<span class="image"><img src="images/img.jpg"
alt="Profile Image" /></span>
<span>
<span>John Smith</span>
<span class="time">3 mins ago</span>
</span>
<span class="message">
Film festivals used to be do-or-die moments for movie
makers. They were where...
</span>
</a>
</li>
<li>
<a>
<span class="image"><img src="images/img.jpg"
alt="Profile Image" /></span>
<span>
<span>John Smith</span>
<span class="time">3 mins ago</span>
</span>
<span class="message">
Film festivals used to be do-or-die moments for movie
makers. They were where...
</span>
</a >
</li>
<li>
<div class="text-center">
<a>
<strong>See All Alerts</strong>
<i class="fa fa-angle-right"></i>
</a>
</div>
</li>
</ul>
</li>
</ul>
</nav>
</div>

</div>
<!-- /top navigation -->

<!-- page content -->
<div class="right_col" role="main">
<!-- <div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="col-md-3 col-sm-3 col-xs-12">
<input type="search" class="form-control input-sm"
placeholder="Employee Id" aria-controls="datatable-fixed-header">
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
<input type="search" class="form-control input-sm"
placeholder="Employee Name" aria-controls="datatable-fixed-header">
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
<input type="search" class="form-control input-sm"
placeholder="Month" aria-controls="datatable-fixed-header">
</div>
<div id="dly_rpt_btn">
<button type="button" class="btn btn-success btn-sm">Clear
<i class="fa fa-eraser"></i></button>
<button type="button" class="btn btn-danger btn-sm">Print
<i class="fa fa-print"></i></button>

<button type="button" class="btn btn-primary btn-sm">Filter
<i class="fa fa-filter"></i></button>
</div>
</div>
</div> -->
<div class=" form">
<div class="field-wrap">
<h2>PRODUCTION MONITORING SHEET</h2>
<select class="form-control" name="month" id="selMonth">
<option value="0">Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</div>

<div class="field-wrap">
<input type="submit" class="button button-block"
value="Search" id="search" />
</div> </div>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">

<div class="x_content">

<div id="datatable-fixed-header_wrapper"
class="dataTables_wrapper form-inline dt-bootstrap no-footer">

<div class="row">
<div class="table-responsive">
<table class="table table-bordered jambo_table
bulk_action" id="Production_monitor">
<thead>
<tr role="row">
<th class="column-title">Date</th>
<th class="column-title">1</th>
<th class="column-title">2</th>
<th class="column-title">3</th>
<th class="column-title">4</th>
<th class="column-title">5</th>
<th class="column-title">6</th>
<th class="column-title">7</th>
<th class="column-title">8</th>
<th class="column-title">9</th>
<th class="column-title">10</th>
<th class="column-title">11</th>
<th class="column-title">12</th>
<th class="column-title">13</th>
<th class="column-title">14</th>
<th class="column-title">15</th>
<th class="column-title">16</th>
<th class="column-title">17</th>
<th class="column-title">18</th>
<th class="column-title">19</th>
<th class="column-title">20</th>
<th class="column-title">21</th>
<th class="column-title">22</th>
<th class="column-title">23</th>
<th class="column-title">24</th>
<th class="column-title">25</th>
<th class="column-title">26</th>
<th class="column-title">27</th>
<th class="column-title">28</th>
<th class="column-title">29</th>
<th class="column-title" >30</th>
<th class="column-title" >31</th>
</tr>

</thead>

<!--

<tbody>

<tr class=''>
<th class="text-center">SHIFT(A+B)</th>

<!-- <th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
<th class="text-center" rowspan="2"></th>
</tr>
<tr class=' '>
<th class="column-title">AF OFF(KWP&KZK)</th>

</tr>
<tr class=' '>
<th class="text-center">PDI OFF(KWP&KZK)</th>

<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
</tr>

</tbody> -->
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->

<!-- footer content -->




</div>

<!-- /footer content -->



<!-- jQuery -->
<script src="vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="vendors/nprogress/nprogress.js"></script>
<!-- Chart.js -->
<script src="vendors/Chart.js/dist/Chart.min.js"></script>
<!-- gauge.js -->
<script src="vendors/gauge.js/dist/gauge.min.js"></script>
<!-- bootstrap-progressbar -->
<script src="vendors/bootstrap-progressbar/bootstrap-progressbar.min.js">
</script>
<!-- iCheck -->
<script src="vendors/iCheck/icheck.min.js"></script>
<!-- Skycons -->
<script src="vendors/skycons/skycons.js"></script>
<!-- Flot -->
<script src="vendors/Flot/jquery.flot.js"></script>
<script src="vendors/Flot/jquery.flot.pie.js"></script>
<script src="vendors/Flot/jquery.flot.time.js"></script>
<script src="vendors/Flot/jquery.flot.stack.js"></script>
<script src="vendors/Flot/jquery.flot.resize.js"></script>
<!-- Flot plugins -->
<script src="vendors/flot.orderbars/js/jquery.flot.orderBars.js">
</script>
<script src="vendors/flot-spline/js/jquery.flot.spline.min.js"></script>
<script src="vendors/flot.curvedlines/curvedLines.js"></script>
<!-- DateJS -->
<script src="vendors/DateJS/build/date.js"></script>
<!-- JQVMap -->
<script src="vendors/jqvmap/dist/jquery.vmap.js"></script>
<script src="vendors/jqvmap/dist/maps/jquery.vmap.world.js"></script>
<script src="vendors/jqvmap/examples/js/jquery.vmap.sampledata.js">
</script>
<!-- bootstrap-daterangepicker -->
<script src="vendors/moment/min/moment.min.js"></script>
<script src="vendors/bootstrap-daterangepicker/daterangepicker.js">
</script>

<!-- Datatables -->
<script src="vendors/datatables.net/js/jquery.dataTables.min.js">
</script>

<script src="vendors/datatables.net-bs/js/dataTables.bootstrap.min.js">
</script>
<script src="vendors/datatables.net-buttons
/js/dataTables.buttons.min.js"></script>
<script src="vendors/datatables.net-buttons-
bs/js/buttons.bootstrap.min.js"></script>
<script src="vendors/datatables.net-buttons/js/buttons.flash.min.js">
</script>
<script src="vendors/datatables.net-buttons/js/buttons.html5.min.js">
</script>
<script src="vendors/datatables.net-buttons/js/buttons.print.min.js">
</script>
<script src="vendors/datatables.net/js/dataTables.editor.min.js">
</script>
<script src="vendors/datatables.net-
fixedheader/js/dataTables.fixedHeader.min.js"></script>
<script src="vendors/datatables.net-
keytable/js/dataTables.keyTable.min.js"></script>
<script src="vendors/datatables.net-
responsive/js/dataTables.responsive.min.js"></script>
<script src="vendors/datatables.net-responsive-
bs/js/responsive.bootstrap.js"></script>
<script src="vendors/datatables.net-
scroller/js/dataTables.scroller.min.js"></script>


<!-- Custom Theme Scripts -->
<script src="js/custom.min.js"></script>
<script src="js/Production_monitor.js"></script>

</body>
</html>

但它不起作用。请帮助我。

最佳答案

试试这段代码

$(document).ready(function() {
$("#search").click(function() {
var monthSelect = $("#selMonth").val();
console.log(monthSelect);
//var monthSelect = e.options[e.selectedIndex].value;
var tid = null;

if(monthSelect == '4'|| monthSelect == '6'|| monthSelect == '9'|| monthSelect == '11') {
$('#Production_monitor thead tr th').each(function (event) {
if($(this).text() == '31'){
$(this).remove();
}
});
}

if(monthSelect == '2') {
$('#Production_monitor thead tr td').each(function (event) {
tid = $(this).attr('id');

if($(this).text() == '31'){
$(this).remove();
}

if($(this).text() == '30'){
$(this).remove();
}
});
}
});
});

working fiddle

关于javascript - 如何在显示月份数据时删除特定日期列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53625937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com