(function ($) {
var test = function (options) {
var ids = {};
views = {
years: 'datepickerViewYears',
moths: 'datepickerViewMonths',
days: 'datepickerViewDays'
};
testalert = function () {
alert('This is a testalert');
};
var defaults = {
foreground: 'red',
background: 'yellow'
};
var opts = $.extend(defaults, options);
return {
test1: function () {
return this.each(function () {
alert(opts.foreground);
//testalert();
});
},
test2: function () {
alert(opts.background);
alert('This is a test2. This is only a test2.');
}
};
} ();
$.fn.extend({
test3: test.test1,
test4: test.test2
});
})(jQuery); 调用:
$('#widgetCalendar').test3({
foreground: 'blue'
});结果就只RED,不是BLUE,不知道为什么参数就是传不进去。
var test = function (options) {
var ids = {};
views = {
years: 'datepickerViewYears',
moths: 'datepickerViewMonths',
days: 'datepickerViewDays'
};
testalert = function () {
alert('This is a testalert');
};
var defaults = {
foreground: 'red',
background: 'yellow'
};
var opts = $.extend(defaults, options);
return {
test1: function () {
return this.each(function () {
alert(opts.foreground);
//testalert();
});
},
test2: function () {
alert(opts.background);
alert('This is a test2. This is only a test2.');
}
};
} ();
$.fn.extend({
test3: test.test1,
test4: test.test2
});
})(jQuery); 调用:
$('#widgetCalendar').test3({
foreground: 'blue'
});结果就只RED,不是BLUE,不知道为什么参数就是传不进去。
看看官方demo 。
根本就没有options传进去test内定义的默认属性是什么就一直会是什么.
刚接触jquery不久,还望指教!
var defaults = {
foregrorounund: 'red',
backgd: 'yellow',
locale: {
days: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"],
daysShort: ["日", "月", "火", "水", "木", "金", "土", "日"],
daysMin: ["日", "月", "火", "水", "木", "金", "土", "日"],
months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
monthsShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
weekMin: '週'
}
};
var opts = $.extend(defaults, options);return {
test1: function () {
var opts = $.extend(defaults, arguments[0]);