From the course: JavaScript: Ajax and Fetch
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Modify the DOM - JavaScript Tutorial
From the course: JavaScript: Ajax and Fetch
Solution: Modify the DOM
(upbeat electronic music) - [Narrator] To get the part data into the dom, the first thing I need is references to a couple more dom elements, and we've done this before. So, after parkSection, I'm going to create a new const called parkName, and that's going to be document.querySelector, and it's going to be #specials h2 a. And then we also need one for the description, so I'm going to call this parkDesc. That's going to be document.querySelector, and that's just #specials, space, p. And then, in the parkUpdateUISuccess function, I want to parse data variable, storing the parsed version of the data. So I will start with a const parsedData. And that's JSON.parse data. And then we'll change our console.log to parseData. And so, just saving this, starting my viewer, checking out the console, and after a moment, I should get a response. And there we go. And so now I can see the data, which is an object, and if I start digging in, I can see that object has this property that has a lot more…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
What is the DOM?3m 19s
-
(Locked)
Select elements with vanilla JavaScript3m 43s
-
(Locked)
Request data in response to an event4m 14s
-
(Locked)
Add an event listener2m 12s
-
(Locked)
Work with JSON data6m 52s
-
(Locked)
Modify form values with vanilla JavaScript4m 58s
-
(Locked)
Modify element content with vanilla JavaScript5m 49s
-
(Locked)
Challenge: Modify the DOM58s
-
(Locked)
Solution: Modify the DOM7m 55s
-
-
-
-
-