简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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