How to create a custom jquery function with brackets and parameters

老子叫甜甜 提交于 2019-12-02 09:32:59

If you want to use:

check({ timer: 1000, redo: 4000, displayAt: 'someID' });

with jquery.fn.extend your function would be declared like so:

check: function(options) {
    // Get the timer value
    var timerValue = options.timer;
    // Get the redo value
    var redoValue = options.redo;
    ...
}

Standalone, it would look like this:

function check(options) {
    // Get the timer value
    var timerValue = options.timer;
    // Get the redo value
    var redoValue = options.redo;
    ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!