Bug Tracker

Modify

Ticket #6160 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

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

Description

 http://christianhaller.com/input.html

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

Attachments

Bildschirmfoto 2010-02-24 um 12.31.31.png Download (46.4 KB) - added by christianhaller 4 years ago.
alert in opera 10.5 on mac

Change History

Changed 4 years ago by christianhaller

alert in opera 10.5 on mac

comment:1 Changed 4 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 4 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 4 years ago by dmethvin

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

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.