Skip to main content

Bug Tracker

Side navigation

#9433 closed bug (invalid)

Opened May 26, 2011 02:39PM UTC

Closed May 27, 2011 12:34AM UTC

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

Attachments (0)
Change History (2)

Changed May 26, 2011 03:12PM UTC by timmywil comment:1

component: unfiledevent
priority: undecidedlow

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.

Changed May 27, 2011 12:34AM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed
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.