Skip to content

Clarify description of .val( array ) #712

Closed
@gibson042

Description

@gibson042

Ref jquery/jquery#2195

The paragraph on https://api.jquery.com/val/#val-value starting with "Passing an array of element values" is inaccurate, and less clear than it could be. In actuality, we implement two similar but distinct special behaviors for array input, both effectively updating the affected collection to the intersection of provided input with possible values:

  • checkbox and radio: check/uncheck based on whether or not their value is in the array
  • select elements: select/unselect options based on whether or not their value is in the array

Although jQuery does not directly touch elements outside the context collection, the .val setter can affect them by triggering native behavior restricting to 1 the maximum count of checked radio inputs in a group or selected options in a select-one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions