Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery add input

Tags:

jquery

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

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

thanks

I am 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++;
 });
like image 793
Vamsi Krishna B Avatar asked Jul 12 '26 22:07

Vamsi Krishna B


1 Answers

Your HTML is messed up:

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

should be

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

The original was missing the "=" and the double-quote character for the "name" attribute value. Also you don't need to self-close <input> tags.

like image 164
Pointy Avatar answered Jul 14 '26 12:07

Pointy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!