Reputation: 83
I have this really simple fiddle set up, if someone could point out why it's not working I'd really appreciate it, been struggling to figure this out for some time now.
Here's the code:
$('input[type=file]').change(function () {
if ($(this).val()) {
alert('This thing works.');
$(this).append('<input type="file" name="test">');
} else {
$(this).remove();
}
});
Upvotes: 0
Views: 90
Reputation: 74738
use .after()
or .before()
or .inserAfter()
:
$(this).after('<input type="file" name="test">');
Upvotes: 1
Reputation: 37381
You can't append anything to an input
, use .after
or .replaceWith
. The input is an element that may not contain child elements.
Upvotes: 6