.val method returning "on" for dynamically created radio buttons in ie9
|Reported by:||garybentley||Owned by:||timmywil|
- 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.
<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); </script>
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.
Change History (8)
comment:2 Changed 5 years ago by rwaldron
- Component changed from unfiled to attributes
- Owner set to garybentley
- Status changed from new to pending
comment:5 Changed 5 years ago by dmethvin
- Priority changed from undecided to high
- Status changed from pending to open
comment:6 Changed 5 years ago by timmywil
- Milestone changed from 1.next to 1.6
- Owner changed from garybentley to timmywil
- Status changed from open to assigned