I have been trying to make a input block which cover the whole part of it's container. Also define the other block which cover the whole part of container when input has taken. So I need the feature that, If a container has two flex item, one can be hide at a time , and other will be displayed.Initially id=show-first
is the shown and style of id="show-after"
is display:none;
.
Here is the code:-
<div id="container">
<div class="flex-item" id="show-first">Enter the name
<input type="text" id="name"></input>
<input type="submit" name="Play" onclick="swapElement()"></input>
</div>
<div class="flex-item" id="show-after">After input taken show these to full container
</div>
</div>
Javascript code is:-
function swapElement(){
var name = document.getElementById('name').value;
document.getElementById('show-first').style.display = 'none';
document.getElementById('show-after').style.display = 'block';
//not understand what to define for flex item in display property
}
My code is not working, only first element is showing , even after taking input the script of display property not working. I am interested more in methods using javascript, and have no knowledge of jQuery.