Ticket #8329 (closed bug: duplicate)
IE bug when appending html button
| Reported by: | kevin_aceace@… | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | attributes | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
The following line of code causes a javascript error in IE8 (and probably older versions) but works fine in FireFox:
$('<button/>').addClass('btnShowAll').attr({title: 'Show All, No Search Conditions', type: 'button'}).html('Show All').appendTo('body');
If you remove the type attribute from the attr array, it works fine. I am currently working around the bug by using the following line of code which works fine in both browsers:
$('<button class="btnShowAll" type="button" title="Show All, No Search Conditions">Show All</button>').appendTo('body')
According to w3schools ( http://www.w3schools.com/tags/att_button_type.asp), type="button" is the default for IE and not the W3C standard which is type="submit" but I don't think this shouldn't cause an error.
Change History
comment:2 Changed 2 years ago by dmethvin
- Status changed from new to closed
- Resolution set to duplicate
Sorry but IE won't allow you to change the type of a button. See the remarks here and in the dup:
http://msdn.microsoft.com/en-us/library/ms534700%28v=vs.85%29.aspx
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

jsfiddle link with test case: http://jsfiddle.net/m9SVV/