From the course: JavaScript: Ajax and Fetch
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Modify element content with vanilla JavaScript - JavaScript Tutorial
From the course: JavaScript: Ajax and Fetch
Modify element content with vanilla JavaScript
Selecting form elements is no different from selecting other DOM elements. You can use query selector, query selector all or any of the older, more specific methods, but getting or setting content from non form elements involves a different property text content. You can also reference any attribute of an element using .notation. For instance, you use .src for the source attribute of an image tag. The one exception is the class attribute, which requires you to use class name instead. To avoid confusion with the JavaScript class keyword, in some design systems, it's common for an element to have multiple class names assigned, so it can be more convenient to use the class list property and its add and remove methods to manipulate which classes are assigned to an element. We can try this out by starting to customize what happens on our National Park Service request in the HTML. All of this park data is going to go in the div element with the ID specials. So I'll do a search on that. And…
Contents
-
-
-
-
-
What is the DOM?2m 45s
-
Select elements with vanilla JavaScript3m
-
(Locked)
Request data in response to an event5m 8s
-
(Locked)
Add an event listener2m 13s
-
(Locked)
Work with JSON data4m 31s
-
(Locked)
Modify form values with vanilla JavaScript4m 39s
-
(Locked)
Modify element content with vanilla JavaScript4m 14s
-
(Locked)
Challenge: Modify the DOM52s
-
(Locked)
Solution: Modify the DOM6m 29s
-
-
-
-