I am writing a jQuery plugin. There are some default options and I can change them on HTML, but how can I change an option if it consists of an array?
Here is the code in plugin:
(function($){
$.fn.extend({
aniTag: function(options) {
var defaults = {
radius: 25,
defaultradius: 0,
enableTilt: true,
tilt : 20,
random : true,
randomMax : 25 ,
};
var colors = new Array('4AC7ED', 'FDC015', '9F78EC', 'F25C33');
var options = $.extend(defaults, options);
return this.each(function() {
var o = options;
//some stuff
});
}
});
})(jQuery);
Here is the html usage:
<script type="text/javascript">
$(document).ready(function() {
$('.tags').aniTag({enableTilt: false});
});
</script>
As you can see I can change enableTilt option. What I need to do is to change the values in the color array. Yes, I know I need to put that array in defaults var, but I don’t know how to do it.
Add your array of colors to your defaults like so
Then you can overwrite them with
Fiddle Demo: http://jsfiddle.net/Beufe/1/