简体   繁体   English

如何在jQuery中实现选项?

[英]How do I implement options in jQuery?

I'm using a jQuery plugin for modals to work on my website, the plugin/code has the option to change the background color of the modal, if you go at the bottom of the plugin's website you'll see the options. 我正在使用jQuery插件进行模态在我的网站上工作,插件/代码可以选择更改模式的背景颜色,如果你在插件的网站底部你会看到选项。

I'm sure this is probably something very simple, I'm just not sure how to implement it in the plugin's initialization code which looks like this: 我确定这可能非常简单,我只是不确定如何在插件的初始化代码中实现它,如下所示:

<script>
  $("#demo01").animatedModal();
</script>

Any help would be highly appreciated. 任何帮助将受到高度赞赏。

Thanks! 谢谢!

I don't know that library, but usually you pass in an object to the function. 我不知道那个库,但通常你会将一个对象传递给该函数。 So, 所以,

$("#demo01").animatedModel( {optionName: optionValue} );

You could always define the object before-hand as well. 您也可以事先定义对象。

var options = { optionName: optionValue };

$("#demo01").animatedModel(options);

Options are basically passed in the function as a object. 选项基本上作为对象传递给函数。 I hope it will work. 我希望它能奏效。

$("#demo01").animatedModal({
    animatedIn:'zoomIn',
    animatedOut:'bounceOut',
    color:'#39BEB9',
    beforeOpen: function() {

        // do something before open
    },
    afterClose: function() {
      //do something after close

    }
});
 $("#demo01").animatedModal({ 
    color: 'color' 
});

And if you want to add more options: 如果您想添加更多选项:

 $("#demo01").animatedModal({ 
    option: value,
    option: value,
    option: value
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM