Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.val(value) documentation should discuss checkboxes more accurately #991

Open
ghost opened this issue Oct 19, 2016 · 1 comment
Open

.val(value) documentation should discuss checkboxes more accurately #991

ghost opened this issue Oct 19, 2016 · 1 comment
Assignees

Comments

@ghost
Copy link

ghost commented Oct 19, 2016

I created the following issue on the jQuery forums:

http://forum.jquery.com/topic/val-value-does-not-work-on-checkboxes-if-value-is-not-an-array

I like the alternative method brought up by Jake, as it seems more clean. The way that jQuery works does make sense; however, the documentation is misleading. It doesn't state that the use of an Array is required, rather it states that you can use Arrays. I would add a note related to Jakes alternate method for checkboxes, as a better way of working with checkboxes.

Take it easy,
Will

@AurelioDeRosa
Copy link
Member

In the documentation we have:

val() allows you to pass an array of element values. This is useful when working on a jQuery object containing elements like <input type="checkbox">, <input type="radio">, and <option>s inside of a <select>. In this case, the inputs and the options having a value that matches one of the elements of the array will be checked or selected while those having a value that doesn't match one of the elements of the array will be unchecked or unselected, depending on the type. In the case of <input type="radio">s that are part of a radio group and <select>s, any previously selected element will be deselected.

Is this description good enough for you or would you expect something different?

@AurelioDeRosa AurelioDeRosa self-assigned this Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant