Skip to content

jQuery change in .attr() use to .prop() #40

Description

@cosmicnet

Hi,

.attr() will not change the 'checked' property the way it used to, at least not consistently among browsers and platforms. Instead now .prop() must be used:
http://api.jquery.com/prop/

You are using .attr() to change the 'checked' property on line 141:
if ( typeInput == "radio" || typeInput == "checkbox" ) copiedInput.attr( "checked", $(this).is(":checked") );
should now be:
if ( typeInput == "radio" || typeInput == "checkbox" ) copiedInput.prop( "checked", $(this).is(":checked") );

The same issue stands for 'selected' on line 145:
if ( $(this).is(":selected") ) $("option", copiedInput).eq( i ).attr( "selected", true );
should now be:
if ( $(this).is(":selected") ) $("option", copiedInput).eq( i ).prop( "selected", true );

To my knowledge, the other uses of .attr() in your code are ok.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions