$ W Method
Splits a string into an Array, treating all whitespace as delimiters. Equivalent to Ruby's % w {foo bar} or Perl's qw (foo bar ).
Copy codeThe Code is as follows: function $ w (string ){
If (! Object. isString (string) return [];
String = string. strip ();
Return string? String. split (/\ s +/): [];
}
This method divides the string into arrays with blank characters and returns the result.
Example:Copy codeThe Code is as follows: $ w ('apples bananas kiwis ') //-> ['append', 'banas', 'kiwis']
$ F Method
Returns the value of a form control. This is a convenience alias of Form. Element. getValue.Copy codeThe Code is as follows: var $ F = Form. Element. Methods. getValue;
// ====> GetValue ()
GetValue: function (element ){
Element = $ (element );
Var method = element. tagName. toLowerCase ();
Return Form. Element. Serializers [method] (element );
}
// ====> Serializers
Form. Element. Serializers = {
Input: function (element, value ){
Switch (element. type. toLowerCase ()){
Case 'checkbox ':
Case 'Radio ':
Return Form. Element. Serializers. inputSelector (element, value );
Default:
Return Form. Element. Serializers. textarea (element, value );
}
},
InputSelector: function (element, value ){
If (Object. isUndefined (value) return element. checked? Element. value:
Null;
Else element. checked = !! Value;
},
Textarea: function (element, value ){
If (Object. isUndefined (value) return element. value;
Else element. value = value;
},
// Omitted. this object will be described in detail later.
......
// ====> Object. isUndefined
Function isUndefined (object ){
Return typeof object = "undefined ";
}
This function returns the value of the input parameter. From Form. element. the method defined in the Serializers object can be seen that the $ F method obtains the value of the Form element. If you define a div and call this method, the Form will be thrown. element. serializers [method] is not a function exception. If the specified ID does not exist, an element has no properties exception is thrown.
In the Form. Element. Serializers method, first check whether the value parameter exists. If it exists, it is equivalent to assigning a value to the element Parameter. If it does not exist, the element value is returned.