$w method
Splits a string into the Array, treating all whitespace as delimiters. Equivalent to Ruby ' s%w{foo bar} or Perl ' s QW (foo bar).
Copy Code code as follows:
function $w (string) {
if (! Object.isstring (String)) return [];
string = String.strip ();
return string? String.Split (/\s+/): [];
}
The method is to divide the string into an array with whitespace characters and then return.
Example:
Copy Code code as follows:
$w (' Apples bananas Kiwis ')//-> [' apples ', ' bananas ', ' Kiwis ']
$F method
Returns the value of a form control. This is a convenience alias of Form.Element.getValue.
Copy Code code 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, in the future when speaking of this object in detail
......
====> object.isundefined
function isundefined (object) {
Return typeof object = = "undefined";
}
This function finally returns the value of the passed-in parameter. The method defined from the Form.Element.Serializers object shows that the $F method gets the value of the form element, and if you define a div and then call this method, it throws the Form.element.serializers[method ' Is ' not ' a function exception, which will throw the element has no properties exception if the given ID does not exist.
The method inside the Form.Element.Serializers first checks whether the value of this parameter exists, the existence is equivalent to assigning a value to the element parameter, and does not exist will return the value of element