diff --git a/categories.xml b/categories.xml index 55038248..d4d31106 100644 --- a/categories.xml +++ b/categories.xml @@ -414,6 +414,14 @@ var files = event.originalEvent.dataTransfer.files;
]]> + + + + diff --git a/entries/load-event.xml b/entries/load-event.xml index d95f81bc..e3739cb7 100644 --- a/entries/load-event.xml +++ b/entries/load-event.xml @@ -1,5 +1,5 @@ - + .load() Bind an event handler to the "load" JavaScript event. @@ -76,4 +76,5 @@ $( "img.userIcon" ).load(function() { + diff --git a/entries/size.xml b/entries/size.xml index 2d092a37..e7dd1223 100644 --- a/entries/size.xml +++ b/entries/size.xml @@ -1,5 +1,5 @@ - + .size() 1.0 @@ -66,4 +66,5 @@ $( document.body ) + diff --git a/entries/unload.xml b/entries/unload.xml index 173d560e..1306ddd6 100644 --- a/entries/unload.xml +++ b/entries/unload.xml @@ -1,5 +1,5 @@ - + .unload() 1.0 @@ -46,4 +46,5 @@ $( window ).unload(function() { + diff --git a/entries/val.xml b/entries/val.xml index 1ba0c365..73d9d521 100644 --- a/entries/val.xml +++ b/entries/val.xml @@ -11,8 +11,10 @@ Get the current value of the first element in the set of matched elements. -

The .val() method is primarily used to get the values of form elements such as input, select and textarea. When the first element in the collection is a select-multiple (i.e., a select element with the multiple attribute set), it returns an array containing the value of each selected option, or null if no options are selected. When called on an empty collection, it returns undefined.

+

The .val() method is primarily used to get the values of form elements such as input, select and textarea. When called on an empty collection, it returns undefined.

+

When the first element in the collection is a select-multiple (i.e., a select element with the multiple attribute set), .val() returns an array containing the value of each selected option. As of jQuery 3.0, if no options are selected, it returns an empty array; prior to jQuery 3.0, it returns null.

For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example:

+

jQuery 3 changes the behavior of this method to return an empty array if a collection is a select-multiple and no options are selected.


 // Get the value from a dropdown select
 $( "select.foo option:selected").val();
@@ -27,7 +29,7 @@ $( "input:checkbox:checked" ).val();
 $( "input:radio[name=bar]:checked" ).val();
       
-

Note: At present, using .val() on textarea elements strips carriage return characters from the browser-reported value. When this value is sent to the server via XHR however, carriage returns are preserved (or added by browsers which do not include them in the raw value). A workaround for this issue can be achieved using a valHook as follows:

+

Note: At present, using .val() on textarea elements strips carriage return characters from the browser-reported value. When this value is sent to the server via XHR, however, carriage returns are preserved (or added by browsers which do not include them in the raw value). A workaround for this issue can be achieved using a valHook as follows:


 $.valHooks.textarea = {
@@ -43,6 +45,8 @@ $.valHooks.textarea = {
 function displayVals() {
   var singleValues = $( "#single" ).val();
   var multipleValues = $( "#multiple" ).val() || [];
+  // When using jQuery 3:
+  // var multipleValues = $( "#multiple" ).val()
   $( "p" ).html( "Single: " + singleValues +
     " Multiple: " + multipleValues.join( ", " ) );
 }
@@ -115,17 +119,17 @@ $( "input" )
       1.4
       
         
-             
-                 
+        
+        
         A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
       
     
     Set the value of each element in the set of matched elements.
     
       

This method is typically used to set the values of form fields.

-

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 don't match one of the elements of the array will be unchecked or unselected, depending on the type. In case of <input type="radio">s that are part of a radio group and <select>s, any previously selected element will be deselected.

+

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.

Setting values using this method (or using the native value property) does not cause the dispatch of the change event. For this reason, the relevant event handlers will not be executed. If you want to execute them, you should call .trigger( "change" ) after setting the value.

-

The .val() 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:

+

The .val() method allows setting 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:


 $( "input:text.items" ).val(function( index, value ) {
   return value + " " + this.className;