In this lesson, we're going to look at creating and inserting new elements into the Document Object Model. So let's see what we've got so far. Got your garden variety select box here, and I have a size of five specified so that it comes out as a list box, and we've got some existing option elements. Let's say, for example, maybe this is a travel site. People want to choose a city to visit. We give them some default choices. We also want to allow them to add a new city to the list and they're going to be able to do that by typing the name of the city right down here. Now this doesn't work yet. We're gonna add the code to make it do that. So, I have an event handler here for the submit button and I have select that represents this box that we've already got out here. So I'm going to go through two steps here. The first thing is I'm going to create my new element and the second is I'm going to insert it into the existing element at a particular place. This is just a little helper method I've got created that allows me to take a city with spaces in the name and turn that into a specific value there. But the crux of this is notice that I'm doing document.createElement and I'm creating an option element. When you want to specify attributes for that element, you can simply tag those on with their values. So, the value is gonna be that lowercased string that I create here and the text is gonna be the actual value from the city box that we've done there. So we've created that. Now how do we get it in to where we want it to be? And we've got a couple of different ways that we can go here. The first is prepend. So I'm taking that select element and this just inserts it before the first child element. So, if we come back up here and take a look, there's your collection of child elements for the select list box. So I'm gonna take that. I'm gonna add that in at the beginning. So let's type in Tokyo and I hit my submit button, and there it makes it the first one there. Now, we could also do that in a slightly different way. We also have insertBefore. InsertBefore takes the item that we're going to insert, the element that we're going to insert, as the first parameter and says where we want it to go. So in this case, child nodes of zero, and let's save that and redo the page again. And this should get it right there at the beginning again. We're certainly not restricted to the very first element. I could say to do that and we end up that it's down here. Now notice that's not the fourth or even fifth element, but what you have to understand about these elements is that the options aren't the only nodes in there. White space, for example, comes in as a text node. So you have to watch very carefully when you're crawling the elements in that collection. Now, if you want to insert it at the end, we can do that as well. Let's try that as one other way to do this. There we go. Append just puts it down at the very last. So if we try this one more time, there we go, that's the last one. So in this lesson we learned a few different ways to make sure that our new element shows up in a particular place in the existing element in the DOM. Thanks for watching. In our next lesson, we'll talk more about navigating through the hierarchy of the Document Object Model.