Skip to main content

Bug Tracker

Side navigation

#8329 closed bug (duplicate)

Opened February 20, 2011 12:07AM UTC

Closed February 20, 2011 01:58AM UTC

Last modified February 20, 2011 12:30PM UTC

IE bug when appending html button

Reported by: kevin_aceace@hotmail.com Owned by:
Priority: low Milestone: 1.next
Component: attributes Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
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.

Attachments (0)
Change History (4)

Changed February 20, 2011 01:20AM UTC by kevin_aceace@hotmail.com comment:1

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

Changed February 20, 2011 01:58AM UTC by dmethvin comment:2

resolution: → duplicate
status: newclosed

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

Changed February 20, 2011 01:58AM UTC by dmethvin comment:3

Duplicate of #8232.

Changed February 20, 2011 12:30PM UTC by jitter comment:4

_comment0: → 1298205047064699
component: unfiledattributes
priority: undecidedlow

This restriction is also noted in the docs. http://api.jquery.com/attr