[英]Wrap Object into a function
How can I turn this piece of code into a function that accept an element as a parameter for example:如何将这段代码转换为接受元素作为参数的函数,例如:
$('#nav-btn li')
.vel('slideUp',
{
duration: 800,
opacity: 1,
stagger: 150
});
functionName('#nav-btn li'); functionName('#nav-btn li');
functionName('#otherElement2'); functionName('#otherElement2');
functionName('#otherElement3'); functionName('#otherElement3');
function functionName(elId){
$(elId).vel('slideUp',
{
duration: 800,
opacity: 1,
stagger: 150
});
}
Now use现在使用
functionName('#nav-btn li');
functionName('#otherElement2');
functionName('#otherElement3');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.