0

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.

1
  • 2
    why not $(wrapper).after('<div> <input class="form-control" value="'+id+'" type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); Commented Nov 29, 2019 at 13:12

1 Answer 1

1

Solved here:

$(wrapper).after('<div> <input class="form-control" value="'+id+'" type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.