Skip to content

Commit

Permalink
changed table to a list
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliedex committed Sep 23, 2024
1 parent 1fc38fa commit c5451d2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
5 changes: 5 additions & 0 deletions assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ body {
height: 100vh;
}

/* Remove the bullet points on the list of events */
#events-list {
list-style-type: none;
}

27 changes: 7 additions & 20 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,16 @@ const eventContainer = document.getElementById("eventContainer");
function renderEvents() {
eventContainer.innerHTML = "";

const eventTable = document.createElement("table");

// Add table headers
const headerRow = document.createElement("tr");
const headerName = document.createElement("th");
headerName.textContent = "Event Name";

headerRow.appendChild(headerName);
eventTable.appendChild(headerRow);

// Loop through events and create rows
// loop through the events and create a list
const row = document.getElementById("events-list");
row.innerHTML = "";
// Loop through the events and create a list
events.forEach(event => {
const row = document.createElement("tr");

const nameCell = document.createElement("td");
nameCell.textContent = event.name;

row.appendChild(nameCell);
eventTable.appendChild(row);
const eventItem = document.createElement("li");
eventItem.textContent = event.name;
row.appendChild(eventItem);
});

// Append the table to the container
eventContainer.appendChild(eventTable);
}
// Render the events table on refresh
renderEvents();
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ <h3 class="testing-testing">Testing out branching!</h3> <!--feel free to delete

<section id="events">
<h2>User Events</h2>

<div id="list_of_events">
<ul id="events-list"></ul>
</div>
<button id="addEvent">+</button>
<div id="eventContainer"></div>
</section>
Expand Down

0 comments on commit c5451d2

Please sign in to comment.