Modify ↓
Ticket #9433 (closed bug: invalid)
IE8 radio buttons can't be selected when jquery onchange event handler is assigned
| Reported by: | Raivo F | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | event | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Probably it happens because jquery adds additional jQueryNNNNN.. attribute to input tags.
HTML source:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello!</title>
<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
</head>
<body>
<form id="form1" action="" method="post">
<label><input type="radio" name="test" value="1"/> Test 1</label>
<label><input type="radio" name="test" value="2"/> Test 2</label>
<br/><br/>
Value: <span id="val">?</span>
</form>
<script type="text/javascript">
$(function()
{
$('input[name=test]').change(function()
{
$('#val').html($('#form1 input:radio:checked').val());
return false;
});
});
</script>
</body>
</html>
Change History
comment:1 Changed 2 years ago by timmywil
- Priority changed from undecided to low
- Component changed from unfiled to event
comment:2 Changed 2 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
The change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT, SELECT, and TEXTAREA. element. Bubbles: Yes Cancelable: No Context Info: None -- http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-htmlevents
So yeah, don't return false or event.preventDefault() on a change event.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

This works fine. There's no need for the return false: http://jsfiddle.net/timmywil/q3Jqu/.
I'm not sure what return false should/could do across browsers for a change event.