$(function(){
$(开发者_开发百科"#getitem").click(function(){
var txtval = $("#txt").val();
var number = ?????
$('<input type="text" name=txt"'+number+'" value="'+txtval+'" />').appendTo('#form');
});
});
Good Day,
Im having trouble solving this one, Basically I'm stuck. All I just need is create a new input type with a unique name preferably incremented numbers. then I have a function that can delete specific new element.. Hope you guys can help me.. Thanks in Advance..
$(function(){
var namecounter = 0;
$("#getitem").click(function() {
namecounter++;
var txtval = $("#txt").val();
$('<input type="text" name="txt' + namecounter + '" value="' + txtval + '" />').appendTo('#form');
});
})
Now the inputs get generated with name as txt1, txt2, ...
精彩评论