Home >Web Front-end >JS Tutorial >Analysis on the principle of passing parameters when jquery refers to methods_jquery

Analysis on the principle of passing parameters when jquery refers to methods_jquery

WBOY
WBOYOriginal
2016-05-16 16:34:081242browse

I often go online to download js plug-ins written by experts. Every time I just need to quote js and set the variables, I have never understood the principle (mainly because the code of the experts is too concise-,-).

This time I figured out how to pass and set multiple (many) parameters.

For example, the method is function lunbo(){};

When calling and setting, write:

lunbo({

  speed:200,

  wrapper:'#id',

  ease:'easing'

})

Then, when obtained within the method:

function lunbo(options){

  var set=$.extend({},options);

  var _speed=set.speed;

  var _wrapper=set.wrapper;

  var _ease=set.ease;

  /*

  使用获取的参数

  */

  }

In addition, when there is really no other way, you can set global variables and use them flexibly.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn