I have the following code:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>24-Hour Time Table</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>48-Hour Time Table</h1>
<table>
<tbody id="time-list">
<!-- Rows will be added here by JavaScript -->
</tbody>
</table>
<script src="script.js"></script>
</body>
</html>
styles.css
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
script.js
const createTimeList = (elementId) => {
const container = document.getElementById(elementId);
const now = new Date();
for (let i = 0; i < 48; i++) {
const date = new Date(now.getTime() + i * 60 * 60 * 1000);
const formattedDate = date.toLocaleDateString();
const formattedTime = date.getHours().toString().padStart(2, '0') + ':00';
const row = document.createElement('tr');
const indexCell = document.createElement('td');
indexCell.textContent = i + 1;
row.appendChild(indexCell);
const timeCell = document.createElement('td');
timeCell.textContent = `${formattedDate} - ${formattedTime}`;
row.appendChild(timeCell);
const checkboxCell = document.createElement('td');
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkboxCell.appendChild(checkbox);
row.appendChild(checkboxCell);
container.appendChild(row);
}
};
document.addEventListener('DOMContentLoaded', () => {
createTimeList('time-list');
});
This code already works as desired.
I would now like to extend it so that it is possible to mark several lines on the mobile phone in a simple way using a swipe gesture. So I swipe from the second to the tenth line with my finger to mark them all.
Unfortunately, I can’t find anything online that could help me.
I tried different code blocks i found for javascript, but nothing works for my case.