Bug Tracker

Opened 6 years ago

Closed 6 years ago

#6160 closed bug (fixed)

attr() not sets value correctly

Reported by: christianhaller Owned by:
Priority: Milestone: 1.4.2
Component: attributes Version: 1.4.1
Keywords: input, checkbox, value, cross browser Cc:
Blocked by: Blocking:

Description

http://christianhaller.com/input.html

Different values in checkboxes, no cross brower compatibility. Look at my testcase.

Change History (3)

comment:1 Changed 6 years ago by Licensed to Gil

I'm pretty sure that IE in particular won't allow you to change the type attribute on an input after it's been created, which I'm guessing is contributing to the difference in functionality.

I can't really see how jQuery could work around it.

What happens if you try $('<input type="checkbox" />').attr('value', 'foo') instead?

comment:2 Changed 6 years ago by icfantv

@Gil is correct. In jQuery 1.3.x, there was a specific comment in the API docs about when creating <input> elements you needed to specify a type as part of the same string due to issues in IE. E.g., $('<input type="text"/>') creates a text field.

Unfortunately, am unable to find that comment in the 1.4 docs, but I'd be willing to bet that this hasn't changed.

comment:3 Changed 6 years ago by dmethvin

  • Resolution set to fixed
  • Status changed from new to closed

Sorry, IE just won't let you (or jQuery) change the type of an input after it's created. I've updated the documentation of jQuery() to clarify this.

Note: See TracTickets for help on using tickets.