我正在创建一个基本的jquery插件,但扩展似乎不起作用..
我以下面的方式调用插件
$('#ccontainer').slide("/json/service.json",6000,700,'true','true','right','800px');
(function($) {
$.fn.slide = function(settings) {
var options = {
service : '',
slideAnimationTime : 5000,
slideSpeed : 800,
onHoverPause : 'true',
autoSlide : 'true',
direction : 'right',
width : ''
};
$.extend(options , settings);
console.log(options.slideSpeed); //doesn't show up new settings as 700 in above case but instead shows old value 800
}
答案 0 :(得分:1)
我认为您需要明确传入一个对象,如:
$('#container').slide({
service: "/json/service.json",
slideAnimationTime: 6000,
slideSpeed: 700,
... // the rest of properties
});