r/JavaScriptTips • • Jun 04 '22

Generating new HTML elements on the page after taking an input

I am trying to build something where after a button press, I want to load a new HTML element (input type). As of now, I am using the DOM model, but is there any way where I can pre-write the HTML code beforehand and only make it visible after I press the button?

4 Upvotes

3 comments sorted by

2

u/ray_zhor Jun 04 '22
style = "visibility: hidden;"

1

u/Varun_123 Jun 04 '22

gotcha! Thanks

1

u/[deleted] Jun 04 '22

Also, instead of making this style change through changing the HTML and doing inline CSS, it's easiest done as adding/removing a CSS class to the element, with that in it.