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

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