Topic: Best practice for creating an HTML element on-the-fly?
I have a modal mask (a semi-transparent div that covers the entire screen so user can't interact with rest of app) that I'm using for an app. However, to use the mask I'm just leaving an empty div on the layout like this:
The CSS takes care of the rest and then I show/hide the mask as needed with JS. It works, but is there a cleaner solution to this? Do I really need a blank div on the layout just taking up space? I'm thinking it would be cleaner to create the div dynamically with JS whenever I need the mask but I wasn't sure if this is a really good practice or looked down upon.
I'm curious how others do something like this. Is it a good idea to create the mask div on the fly and then delete it when the mask is hidden then recreate, etc... ?