tell me how to add etc. using jq...">

JQuery add input

I have <input type="file" name="p1" size="100" />

tell me how to add <input type="file" name="p2" size="100" />etc. using jquery add ..

thank

I'm trying var i = $ ('input'). size () + 1;

$('a.add').click(function() {

$('<input type="file" name"p' + i + 'size="100" />')
    .animate({ opacity: "show" }, "slow")
    .appendTo('#inputs');
    i++;
 });
+3
source share
1 answer

Your HTML is corrupted:

$('<input type="file" name"p' + i + 'size="100" />')

it should be

$('<input type="file" name="p' + i + '" size="100" >')

The original was missing the "=" symbol and the double quote character for the value of the name attribute. Also you do not need to close tags <input>.

+7
source

Source: https://habr.com/ru/post/1784583/


All Articles