Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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:
Blocked by: Blocking:


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 (4)

comment:1 Changed 5 years ago by kevin_aceace@…

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

comment:2 Changed 5 years ago by dmethvin

  • Resolution set to duplicate
  • Status changed from new to closed

Sorry but IE won't allow you to change the type of a button. See the remarks here and in the dup:


comment:3 Changed 5 years ago by dmethvin

Duplicate of #8232.

comment:4 Changed 5 years ago by jitter

  • Component changed from unfiled to attributes
  • Priority changed from undecided to low

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

Last edited 5 years ago by jitter (previous) (diff)
Note: See TracTickets for help on using tickets.