Reputation: 330
So I've came across with this weird behavior, not quite sure what I'm doing wrong Tried searching but no luck...
So basically, I had a simple input, can be anything
<input class="me" type="text" name="me" value="3"></input>
Then I want to copy itself
$(".me").after($(".me").html());
But somehow it's not working, any suggestions? Please note that I don't need .val() and create a new one, I want to copy the whole input tag as there'll be input, textarea, select, etc... Thanks in advance
P.S. if I choose span instead of input, it works fine, which is weird
Upvotes: 0
Views: 58
Reputation: 388446
because .html()
get innerHTML, and input element does not have any inner html, you need to clone the input element
$(".me").after($(".me").clone());
Upvotes: 4