default_value .default-value. ?
, . default_value jQuery node, .
, , , .
, ?
, , .
" " ?
The term namespace indicates a container of functions and variables. If you are creating a new JS library, it is very important to avoid conflict with another library. Therefore, instead of creating a global "load" function, you create a namespace that will contain this function:
var myLibraryUniqueName = {};
myLibraryUniqueName.load = function() {};
Of course, if the library is complex, you can create internal namespaces:
myLibraryUniqueName.loginModule = {};
myLibraryUniqueName.animationModule = {};
...
Then you asked:
if I wanted to apply this to an element with a given ID instead of a group of this class, then using each () seems unnecessary. Like if it will be changed
function defaultValue(node) {
var default_value = node.value;
node.focus(function() {
if(node.value == default_value) {
node.value = '';
}
});
node.blur(function() {
if($.trim(node.value) == '') {
node.value = default_value;
}
}
}
defaultValue($('#id'));
source
share