The example is shown in the picture. The task must be solved using jquery.
Closed due to the fact that off-topic participants are teran , zhurof , Suvitruf ♦ , AK ♦ , 0xdb 14 Sep '18 at 16:44 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- teran, zhurof, Suvitruf, 0xdb
- And what is the actual problem then? - user218976
- First you need to set some value to input and then when you click on the OK button, it should create as many lines on the top of the page as was originally set @Anamnian - Akbar Ilxambaev
- The author, do you know what Google is? You can see what you need, but what you tried to write is not visible. The question looks like some kind of TK. - Vitaly Shebanits September
|
1 answer
Using what function
Using such a function
$("#add").click(function(){ var c = $("#qnt").val(); while(c--){ $("<input>").appendTo("#input-container"); } }); $("#remove").click(function(){ var c = $("#qnt").val(); while(c--){ $("#input-container input").last().remove(); } }); #input-container { background-color: #f0f0f0; padding: 15px;} #input-container input { display: block; margin: 4px; } #options { margin-top: 30px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="input-container"> </div> <div id="options"> <input id="qnt"> <button id="add">OK</button> <button id="remove">Remove</button> </div> - Sorry Bro but your code doesn't work @teran - Akbar Ilxambaev
- @AkbarIlxambaev What does not work in the code above? - Nilsan
- @AkbarIlxambaev let's press the button "Run code" again, enter the number 2, press OK, and make sure that the two inputs, as you wish, do not appear. And only then write to me an appeal, without "you" and "bros", the style of communication of the courtyard gopoty, this resource does not appreciate. - teran
- Please forgive me, everything works correctly. I forgot to connect the library. And how to make the return (delete) button @teran - Akbar Ilxambaev
- @AkbarIlxambaev remove what? All inputs, one from top to bottom, or each individually with its own button? - teran
|
