I have a jquery variable:
var $items = "<input type='text' />";
and I have a cloned element:
var cloneA = $("#element").clone();
I cannot find a way to append cloneA to $items.
What could be the solution?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is that you were not using
$itemsas a jQuery object. You need it to be a jQuery object in order to use the.append()function on it.Wrapping the HTML string in the jQuery variable,
$will create an object with that HTML inside.Try this –
I assume that this is simply pseudo code because you wouldn’t regularly want to be appending elements into an
<input>element. Rather adding<input>fields into an existing element…Something slightly more logical would look like this –