Skip to main content

Bug Tracker

Side navigation

#8570 closed bug (fixed)

Opened March 20, 2011 12:04AM UTC

Closed April 22, 2011 01:34AM UTC

Last modified March 17, 2012 08:42PM UTC

.val method returning "on" for dynamically created radio buttons in ie9

Reported by: garybentley Owned by: timmywil
Priority: high Milestone: 1.6
Component: attributes Version: 1.5.1
Keywords: ie9 Cc:
Blocked by: Blocking:
  • jquery version: 1.5.1
  • browser version: IE 9.0.8112.16421 (other browsers not affected)
  • os + version: Windows 7

If you dynamically create a radio button via "createElement" and then use the :checked selector and the val method to retrieve the value "on" is returned in ie9. This doesn't happen with a radio button created via HTML.

Test code:

<div id="test"></div><input type="submit" onclick="window.alert (jQuery('#test input:checked').val ());" value="Click Me!" /><script src="/js/jquery-1.5.1.js"></script><script>
jQuery.noConflict ();

var el = window.document.createElement ('input');
el.setAttribute ('name', 'hello');
el.setAttribute ('value', 'world');
el.setAttribute ('type', 'radio');

jQuery('#test').append (el);


The expected output is "world" but "on" is returned.

If you use standard html such as:

<input type="radio" name="hello" value="world" />

Then "world" is returned as expected.

This problem doesn't happen in ie8 but in ie8 and below you have to use createElement with the full html specified for the element.

Attachments (0)
Change History (8)

Changed March 20, 2011 12:07AM UTC by anonymous comment:1

Sorry, didn't see the jsfiddle requirement.

Changed March 30, 2011 04:52PM UTC by rwaldron comment:2

component: unfiledattributes
owner: → garybentley
status: newpending

Please take a look at this fiddle and confirm the output:

Changed March 30, 2011 05:04PM UTC by danheberden comment:3

Changed March 30, 2011 07:27PM UTC by dmethvin comment:4

keywords: → ie9

Changed March 30, 2011 07:28PM UTC by dmethvin comment:5

priority: undecidedhigh
status: pendingopen

Changed April 17, 2011 08:31PM UTC by timmywil comment:6

milestone: 1.next1.6
owner: garybentleytimmywil
status: openassigned

Changed April 19, 2011 05:49PM UTC by timmywil comment:7

pull request for review

Changed April 22, 2011 01:34AM UTC by timmywil comment:8

resolution: → fixed
status: assignedclosed

Landing pull request [337]( Value of radio inputs resets when type is set after the value in all IEs. Fixes #8570 ([bug](

Changeset: 3ac9eb7ce37b461a34e303e8b77aa544d313441c