jQuery append breaks my HTML form (with submit button)
Posted
by
JimFing
on Stack Overflow
See other posts from Stack Overflow
or by JimFing
Published on 2011-04-10T15:26:14Z
Indexed on
2013/07/01
10:21 UTC
Read the original article
Hit count: 213
I'm trying to create a form with a submit button via jQuery using append(). So the following:
out.append('<form name="input" action="/createuser" method="get">');
out.append('Username: <input type="text" name="user" />');
out.append('<input type="submit" value="Submit" />');
out.append('</form>');
However, clicking on submit, nothing happens!
However if I do the following:
var s =
'<form name="input" action="/createuser" method="get">' +
'Username: <input type="text" name="user" />' +
'<input type="submit" value="Submit" />' +
'</form>';
out.html(s);
Then the submit button works fine!
I'm happy to use the 2nd method, but would rather know what the problem is here.
Thanks
© Stack Overflow or respective owner