-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayment.js
More file actions
43 lines (37 loc) · 1.34 KB
/
payment.js
File metadata and controls
43 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Payment tabs functionality
document.addEventListener("DOMContentLoaded", function () {
// Get all payment tabs
const paymentTabs = document.querySelectorAll(".payment-tab");
// Get all payment content blocks (we'll add these to the HTML)
const paymentContents = document.querySelectorAll(".payment-content");
// Function to show the selected payment method content
function showPaymentMethod(methodName) {
// Hide all payment contents first
document.querySelectorAll(".payment-content").forEach((content) => {
content.classList.remove("active");
});
// Show the selected payment content
const selectedContent = document.querySelector(
`.payment-content[data-method="${methodName}"]`
);
if (selectedContent) {
selectedContent.classList.add("active");
}
// Update active tab
paymentTabs.forEach((tab) => {
if (tab.textContent.trim() === methodName) {
tab.classList.add("active");
} else {
tab.classList.remove("active");
}
});
}
// Add click event listeners to all payment tabs
paymentTabs.forEach((tab) => {
tab.addEventListener("click", function () {
const methodName = this.textContent.trim();
showPaymentMethod(methodName);
});
});
// Initialize with the first tab (فوري) selected - it's already active in the HTML
});