Skip to content

Commit 068d23e

Browse files
committed
val(): Specified that it does not fire the change event
Fixes gh-79 Closes gh-909
1 parent 33508ae commit 068d23e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

entries/val.xml

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ $( "input" )
124124
<longdesc>
125125
<p>This method is typically used to set the values of form fields. </p>
126126
<p><code>val()</code> allows you to pass an array of element values. This is useful when working on a jQuery object containing elements like <code>&lt;input type="checkbox"&gt;</code>, <code>&lt;input type="radio"&gt;</code>, and <code>&lt;option&gt;</code>s inside of a <code>&lt;select&gt;</code>. In this case, the <code>input</code>s and the <code>option</code>s having a <code>value</code> that matches one of the elements of the array will be checked or selected while those having a <code>value</code> that don't match one of the elements of the array will be unchecked or unselected, depending on the type. In case of <code>&lt;input type="radio"&gt;</code>s that are part of a radio group and <code>&lt;select&gt;</code>s, any previously selected element will be deselected.</p>
127+
<p>Setting values using this method (or using the native <code>value</code> property) does not cause the dispatch of the <code>change</code> event. For this reason, the relevant event handlers will not be executed. If you want to execute them, you should call <code>.trigger( "change" )</code> after setting the value.</p>
127128
<p>The <code>.val()</code> method allows us to set the value by passing in a function. As of jQuery 1.4, the function is passed two arguments, the current element's index and its current value: </p>
128129
<pre><code>
129130
$( "input:text.items" ).val(function( index, value ) {

0 commit comments

Comments
 (0)