Bug Tracker

Ticket #8329 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

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:1 Changed 3 years ago by kevin_aceace@…

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

comment:2 Changed 3 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

comment:3 Changed 3 years ago by dmethvin

Duplicate of #8232.

comment:4 Changed 3 years ago by jitter

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

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

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