console
const cards = [
"3♠️", "4♠️", "5♠️", "6♠️", "7♠️", "8♠️", "9♠️", "10♠️", "J♠️", "Q♠️", "K♠️", "A♠️", "2♠️",
"3♥️", "4♥️", "5♥️", "6♥️", "7♥️", "8♥️", "9♥️", "10♥️", "J♥️", "Q♥️", "K♥️", "A♥️", "2♥️",
"3♦️", "4♦️", "5♦️", "6♦️", "7♦️", "8♦️", "9♦️", "10♦️", "J♦️", "Q♦️", "K♦️", "A♦️", "2♦️",
"3♣️", "4♣️", "5♣️", "6♣️", "7♣️", "8♣️", "9♣️", "10♣️", "J♣️", "Q♣️", "K♣️", "A♣️", "2♣️",
"小王", "大王"
];
const groupedCards = {
"♠️": [],
"♥️": [],
"♦️": [],
"♣️": [],
"特殊": []
};
cards.forEach(card => {
if (card.includes("小王") || card.includes("大王")) {
groupedCards["特殊"].push(card);
} else {
const suit = card.slice(-2);
groupedCards[suit].push(card);
}
});
const cardContainer = document.getElementById("cardContainer");
for (const suit in groupedCards) {
const row = document.createElement("div");
row.className = "card-row";
groupedCards[suit].forEach(card => {
const cardElement = document.createElement("div");
cardElement.className = "card";
cardElement.textContent = card;
cardElement.addEventListener("click", () => {
cardElement.classList.toggle("hidden");
});
row.appendChild(cardElement);
});
cardContainer.appendChild(row);
}
const specialRow = document.createElement("div");
specialRow.className = "card-row";
groupedCards["特殊"].forEach(card => {
const cardElement = document.createElement("div");
cardElement.className = "card";
cardElement.textContent = card;
cardElement.addEventListener("click", () => {
cardElement.classList.toggle("hidden");
});
specialRow.appendChild(cardElement);
});
cardContainer.appendChild(specialRow);
const resetButton = document.getElementById("resetButton");
resetButton.addEventListener("click", () => {
const allCards = document.querySelectorAll(".card");
allCards.forEach(card => {
card.classList.remove("hidden");
});
});
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>欢乐斗地主记牌器</title>
</head>
<body>
<h1>欢乐斗地主记牌器</h1>
<div id="cardContainer"></div>
<button id="resetButton">重置</button>
</body>
</html>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
padding: 20px;
}
.card-row {
display: flex;
gap: 5px;
margin-bottom: 10px;
}
.card {
width: 60px;
height: 80px;
background-color: #007bff;
color: white;
text-align: center;
line-height: 80px;
font-size: 24px;
border-radius: 10px;
cursor: pointer;
}
.card.hidden {
visibility: hidden;
}
#resetButton {
margin-top: 20px;
padding: 10px 20px;
font-size: 18px;
background-color: #28a745;
color: white;
border: none;
border-radius: 10px;
cursor: pointer;
}