开发者

Jquery add input

开发者 https://www.devze.com 2023-02-03 17:18 出处:网络
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 ..

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++;
开发者_开发知识库 });


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消