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
Release: 2016-05-16 16:34:08
Original
1202 people have browsed it

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'

})
Copy after login

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;

  /*

  使用获取的参数

  */

  }
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template