Side navigation
#4914 closed bug (invalid)
Opened July 17, 2009 04:51PM UTC
Closed July 21, 2009 02:28AM UTC
IE8 error when creating a form
Reported by: | jeremywoertink | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | IE8, form, create new form element | Cc: | |
Blocked by: | Blocking: |
Description
When creating a form element, you can't specify attributes for the form while creating the form. The attributes must be assigned after the form has already been created. You can test this in the IE8 console like this.
var form = $('<form action="index.html">');
>>> {...}
$(form).length
>>> 0
var form = $('<form>');
>>> {...}
$(form).attr('action', 'index.html');
>>> {...}
$(form).length
>>> 1
I have not tested this in other versions of IE, but I'm pretty sure it doesn't work in the others as well.
Attachments (0)
Change History (4)
Changed July 20, 2009 03:55AM UTC by comment:1
Changed July 20, 2009 08:32AM UTC by comment:2
With the closing tag on the <form/> it also works on IE8.
Changed July 21, 2009 02:18AM UTC by comment:3
odd that it would work like that since doing
var div = $('<div>');
alert($(div).length);
notice no close tag on the div. This works with every other element that I've tried it on (i.e. table, span, p, div, tr, td)
I guess if it's not a bug, then oh well. Thanks for the info. I tested that in IE8 and it does seem to work.
~Jeremy
Replying to [comment:1 Larry Battle]:
I don't think that's a bug. When creating elements you have to use the close tag. <form/> or <form></form>> var form = $('<form action="index.html"/>'); > > alert( "$(form).length = " + $(form).length ); > alert( "$(form).attr( 'action' ) = " + $(form).attr( 'action' ) ); >Works on IE6 and other browsers, but I'm not sure about IE8. example: http://jsbin.com/uqomo
Changed July 21, 2009 02:28AM UTC by comment:4
resolution: | → invalid |
---|---|
status: | new → closed |
IE's HTML parser is picky sometimes. Always close your tags. Self-closing tags are handled internally by jQuery for situations where there are no attributes, such as "<div />" but for your case you'd need a closing tag.
I don't think that's a bug.
When creating elements you have to use the close tag.
<form/> or <form></form>
Works on IE6 and other browsers, but I'm not sure about IE8.
example:
http://jsbin.com/uqomo