Bug Tracker

Opened 12 years ago

Closed 12 years ago

#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:
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>

Change History (2)

comment:1 Changed 12 years ago by Timmy Willison

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.

comment:2 Changed 12 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.