Working with the custom element
We now have the UI ready for our Weather Widget. Our next step is to retrieve the data from the server and display it in the Weather Widget. Generally, widgets, such as our Weather Widget, will not be present in the HTML directly. Like with the tasks in our Chapter 1, Building a ToDo List, developers often create the element from JavaScript, attach attributes, and append it to the DOM. Also, if they need to make any changes, such as changing the geolocation, they will use a reference to the element in JavaScript to modify its attributes.
This is very common and we have been modifying a lot of DOM elements this way in all our projects. Now, the same will be expected from our custom weather element. The HTMLElement ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access