new file: date.html
modified: script.js
This commit is contained in:
parent
92461c40b2
commit
f8ea0510f2
24
date.html
Normal file
24
date.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>选择日期</title>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>你选择的日期为:</h3>
|
||||
<div id="selectedDate">No date selected</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var dateString = urlParams.get('date');
|
||||
if (dateString) {
|
||||
$('#selectedDate').text(dateString);
|
||||
} else {
|
||||
console.warn('No date found in the URL.');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
38
script.js
38
script.js
@ -43,13 +43,29 @@ $(document).ready(function() {
|
||||
// 删除选项卡
|
||||
$(document).on("click", ".removeTab", function() {
|
||||
var tabName = $(this).data("tab");
|
||||
var activeTab = $(".tablinks.active").data("tab");
|
||||
|
||||
// 记录当前活动的标签页
|
||||
var previousTabButton = $(".tablinks.active").prev(".tablinks");
|
||||
|
||||
// 删除当前标签页
|
||||
$("#" + tabName).remove();
|
||||
$("button[data-tab='" + tabName + "']").remove();
|
||||
|
||||
// 显示第一个选项卡内容
|
||||
// 如果删除的是当前活动的标签页
|
||||
if (tabName === activeTab) {
|
||||
// 显示上一个标签页
|
||||
if (previousTabButton.length > 0) {
|
||||
var previousTab = previousTabButton.data("tab");
|
||||
$("#" + previousTab).show();
|
||||
previousTabButton.addClass("active");
|
||||
} else {
|
||||
// 如果没有上一个标签页,显示第一个标签页
|
||||
$(".tabcontent").hide();
|
||||
$(".tablinks").first().addClass("active");
|
||||
$("#" + $(".tablinks").first().data("tab")).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 绑定选项卡按钮和删除按钮的事件
|
||||
@ -72,16 +88,31 @@ $(document).ready(function() {
|
||||
|
||||
$(".removeTab").off("click").click(function() {
|
||||
var tabName = $(this).data("tab");
|
||||
var activeTab = $(".tablinks.active").data("tab");
|
||||
|
||||
// 记录当前活动的标签页
|
||||
var previousTabButton = $(".tablinks.active").prev(".tablinks");
|
||||
|
||||
// 删除当前标签页
|
||||
$("#" + tabName).remove();
|
||||
$("button[data-tab='" + tabName + "']").remove();
|
||||
|
||||
// 显示第一个选项卡内容
|
||||
// 如果删除的是当前活动的标签页
|
||||
if (tabName === activeTab) {
|
||||
// 显示上一个标签页
|
||||
if (previousTabButton.length > 0) {
|
||||
var previousTab = previousTabButton.data("tab");
|
||||
$("#" + previousTab).show();
|
||||
previousTabButton.addClass("active");
|
||||
} else {
|
||||
// 如果没有上一个标签页,显示第一个标签页
|
||||
$(".tabcontent").hide();
|
||||
$(".tablinks").first().addClass("active");
|
||||
$("#" + $(".tablinks").first().data("tab")).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 初始绑定事件
|
||||
bindTabEvents();
|
||||
$(document).ready(function() {
|
||||
@ -212,6 +243,7 @@ $(document).ready(function() {
|
||||
$('#tbody td').click(function() {
|
||||
var dateString = $(this).data('date');
|
||||
$('#selectedDate').text(dateString);
|
||||
window.location.href = 'date.html?date=' + encodeURIComponent(dateString);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user