Solution: Know Your Browser
Explore how to use JavaScript to interact with the browser environment by manipulating DOM elements and accessing BOM properties. Learn to remove specific HTML tags, update elements with browser name and window size, and dynamically add URL details. This lesson helps you understand practical DOM and BOM manipulation to enhance web pages.
We'll cover the following...
Solution
The final solution to the problem is here.
The above solution shows that we do not alter any elements on HTML directly. Instead, use JavaScript to add/remove elements to DOM and fetch certain information through BOM. Let’s see more detail below.
In the above code, do the following.
-
Delete elements with tag names
'p'and'h2'. The HTML page shows that these elements should be deleted. But do the following for both:-
Fetch all elements with tag names for
'h2'(line 2) and'p'(line 7) withdocument.getElementsByTagNamemethod. -
Because of a
NodeList, iterate the list using aforloop for both. ...
-