When it comes to showing/hiding content, there are two main approaches that I would consider:
- Creating and destroying elements as needed using jQuery's append() and remove() methods.
- Having all elements already in the HTML but hiding/disabling them when necessary.
So, which method is considered best practice? Each approach has its own advantages and disadvantages.
For instance, let's take a website where users can capture a photo with their webcam. The webcam window appears in a separate overlapping window above all other site content. Once a picture is taken, the webcam overlay is removed. In this scenario, you could opt to hide or insert/remove the webcam window.