Nathiel Paulino
Nathiel Paulino

Reputation: 544

append parameter into string with jQuery

I'm generating fields dynamically but I need to add a id in the middle of the string that will be the input.

 var id = uid();
 $(wrapper).after('<div> <input class="form-control" type="text"name="mytext[]"/>').after('<a href="#" class="remove_field">Remove</a></div>');

But it only works if the after is used in the final of enclose tag.

Upvotes: 0

Views: 44

Answers (1)

Roy Bogado
Roy Bogado

Reputation: 4472

Solved here:

$(wrapper).after('<div> <input class="form-control" value="'+id+'" type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>');

Upvotes: 1

Related Questions