Create a dynamic web page titled "Football Time" by utilising DOM manipulation techniques to create and append HTML elements. The page will present detailed information about various football clubs, including details, trophies, and trivia, based on data from the footballClubs
array.
Scroll down to see the detailed requirements for building each section.
Introduction Section
Inside the div
with the class "container", create a div with the class introduction. Inside this div, add an h1
element with the text "Football Time.
Details Section
Create a div
with the class details-section.
All Clubs Section
Create a div
with the id all-clubs-section. Inside this div
, add an h2
element with the text "All Clubs." Create a table with a header (thead) containing one row with four columns labeled "Name," "Country," "League," and "Trophies." Populate the table with data from the footballClubs array, ensuring each club's name, country, league, and trophies won are displayed.
Clubs with More Than 5 Championships Section
Create a div
with the id trophy-70-or-more-section. Inside this div
, add an h2
element with the text "Clubs with More Than 5 Championships." Create a table with a header (thead) containing one row with two columns labeled "Name of the Club" and "Trophies." Filter the footballClubs array to include only clubs with more than 70 trophies and populate this table accordingly.
Premier League Section
Create a div
with the id premier-league-section. Inside this div
, add an h2
element with the text "Premier League." Create an ordered list (ul) with the id premier-league. Filter the footballClubs array to include only clubs from England and populate this list with their names.
Trivia Section
Create a div
with the id trivia-section. Inside this div
, add an h2
element with the text "Trivia Section." Create an ordered list (ul) with the id trivia. Populate this list with details of each club in the format "ClubName from CountryName plays in LeagueName and has won Number championships" using data from the footballClubs array.
Trophies Section
Create a div
element with the id total-trophies-section. Inside this div
, add an h2
element with the text "Total Trophies." Calculate the total number of trophies won by all clubs in the footballClubs array dynamically. Add a p element to display the calculated total number of trophies in the format "In total, all these listed clubs have won X number of trophies."
Make sure all tasks are accomplished using JavaScript for element creation, event handling, and DOM manipulation to enhance user interaction and logging functionality. Make use of the footballClubs
array of objects provided in the code to construct the exercise.
Given below is a screenshot of the completed "Football Time" project. Use it as a reference for how the final page should look. By appropriately assigning the specified classes to the created elements, the styles will automatically be reflected in the output.
We are not displaying the answer for this exercise.
We do this because we want you to challenge yourself
and
not give in to the temptation of looking at the solution.
We also don't want to leave you stuck, so if you feel
you have tried enough and are still unable to solve
this exercise, feel free to ask in our community.
Here is the link to join the community.