如何在jQuery中实现选项?

时间:2021-07-21 14:30:08

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插件modals,插件/代码可以改变模式的背景颜色,如果你到插件网站的底部,你会看到选项。

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!

谢谢!

3 个解决方案

#1


3  

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);

#2


0  

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

    }
});

#3


0  

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

And if you want to add more options:

如果你想添加更多的选项:

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

#1


3  

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);

#2


0  

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

    }
});

#3


0  

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

And if you want to add more options:

如果你想添加更多的选项:

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