Hi Dormilich, I got some idea about jQuery.extends , thanks for your help , pls verify my idea as I know depicted below:
$.extend(target,objects...) --->Extends the target
object with one or more specified objects.Returns the
original,unmodified object.
It's used mainly in creating plugins. For example,
in a plugin function there need some default
objects, some time we need to pass our own
preference(objects), in that time we need
to extend the deafault object with our own
eg:
- (function($) {
-
$.fn.say = function(options) {
-
var ops = {
-
'word' : 'Hello'
-
};
-
return this.each(function() {
-
if (options) {
-
// here I merge the users inputted 'options' object
-
// with my 'ops' object.
-
$.extend(ops, options);
-
}
-
$(this).html(ops.word);
-
});
-
};
-
})(jQuery);
and call this as :
- $(document).ready(function() {
-
$('div').say();
-
});
Would make all div's within a document contain the html 'Hello'.
Now, using $.extend() we can override the word hello with 'goodbye'.
- $(document).ready(function() {
-
$('div').say({word: 'Goodbye'});
-
});
Am I right Dormilich, If my understanding has any
problem advise me
Regards
Anes P.A