javascript - How do I create button that returns to "hidden" data onclick in js, that was previously input by user? -
how create button returns "hidden" data onclick in js, input user?
<html> <script> var input, inputcount = 0; function newinput () { if (input !== undefined) { input.type = "hidden"; } inputcount++; input = document.createelement("input"); input.type = "text"; input.name = input.placeholder = "fname" + inputcount; document.getelementbyid("box").appendchild(input); } </script> <button type="button" onclick="newinput()">add property</button><br/> <form action="#" method="post"> <br/><span id="box"></span><br/><br/> <input type="submit" value="submit"> </form> </html>
i suggest use jquery in programs. it'll make life easier
<button type="button" class="hiding-button">add property</button> <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script> $(".hiding-button").on("click",function(){ newinput(); $(this).hide(); }); </script>
Comments
Post a Comment