$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).
function $w(string) {
if (!Object.isString(string)) return [];
string = string.strip();
return string ? string.split(/s /) : [];
}
This method is used The whitespace character splits the string into an array and returns it.
Example:
$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.
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, we will discuss this object in detail later Description
......
//====> Object.isUndefined
function isUndefined(object) {
return typeof object === "undefined";
}
This function finally returns the value of the passed in parameter. It can be seen from the methods defined in the Form.Element.Serializers object that the $F method obtains the value of the Form element. If you define a div and then call this method, Form.Element.Serializers[method] is not a function exception, if the given ID does not exist, an element has no properties exception will be thrown.
In the method in Form.Element.Serializers, 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 value of the element will be returned.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn