November 2019
Beginner
804 pages
20h 1m
English
This method removes given book collection from the DOM. Again, collections have an identifier and this is what we'll use here, as those identifiers are also present in the DOM that we generate.
The following is the code for the method:
removeBookCollection(identifier: string) {
const bookCollectionDOMNode: HTMLDivElement = document.getElementById(`bookCollection-${identifier}`) as HTMLDivElement;
if (!bookCollectionDOMNode) {
throw new Error("Could not remove the book collection from the DOM. Couldn't find the DOM node");
} else {
bookCollectionDOMNode.remove();
}
}
As you can see, we simply use the remove() method present on DOM nodes. If the DOM node is not found, we again throw an exception ...
Read now
Unlock full access