Reputation: 11557
JavaScript application often use one of the following methods:
display:none
)What is the best case for each of these methods? When should I prefer one over the other, and why?
Upvotes: 2
Views: 59
Reputation: 2789
Things to considerate:
I choose A combination of both to optimize the load time.
Upvotes: 1
Reputation: 227240
It all depends on what you're trying to do.
If you want to add elements to a page, and you know how many you need, you can have them on the page and hide/show them when needed.
If you want to add a dynamic number of new elements, you can just make them on-the-fly, because having them on the page to begin with may not work if you need more than you added.
You can also clone existing elements, and change their attributes, to add elements to a page.
This all depends on what you're trying to do.
For example:
So, there are different methods for what you are trying to do.
Upvotes: 2