5.8. The DOM is connected to what a customer seesLet's take a closer look at exactly what happens when you replace an element in the DOM: divHere's the part of the DOM tree that we're working on.Here's the <form> we want to replace with an order confirmation.Here's what's going on in the browser as we change the DOM tree. formWe need to replace the <form> element from the DOM tree... p...and add the <p> in the place of the <form> element. p Order confirmationThis won't show up in the web browser until you've added it in to the DOM tree. Here's the DOM tree after you've replaced the <form> element with the new <p> element... divNow the <form> is nowhere to be seen. Perfect! pAt the end of this process, here's what the DOM tree should look like. pThe <p> with the order confirmation is now all that the customer sees. Order confirmation When the <p> replaced the <form> in the DOM tree, the browser updated the web page to match. All of this happens without page reloads... and no waiting around!
|