如下,请问大家是什么意思,看不懂
<script type="text/javascript">
ddaccordion.init({
headerclass: "submenuheader", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click","clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='images/plus.png' class='statusicon' />", "<img src='images/minus.png' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
})
</script>
<script type="text/javascript">
ddaccordion.init({
headerclass: "submenuheader", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click","clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='images/plus.png' class='statusicon' />", "<img src='images/minus.png' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
})
</script>
解决方案 »
- 如何把若干下拉列表里面的内容合并在一起输出到一个文本域内-急!
- Comments For Cookies的工作原理?
- 无缝滚动JavaScript代码问题 求助!
- 壮士们,帮帮我吧~绕昏了头!
- ASP显示日期和星期的代码
- 请大家帮我看下哪里有问题?
- 关于prototype1.4中 String.inspect的问题
- 绑定事件的代码怎样才能写进js文件里?
- javascript中如何实现这样的数据传递 (个人认为有难度,有兴趣的朋友过来瞧瞧)
- 急!急!急!高分求救一个关于JavaScript的问题(100分!)
- 在线等答案,JQUERY获取服务端控件事件的问题
- 疑难--用数组实现的可多次添加和删除的功能
看看
ddaccordion.init({
headerclass: "submenuheader",
contentclass: "submenu",
revealtype: "click",
mouseoverdelay: 200,
collapseprev: true,
defaultexpanded: [],
onemustopen: false,
animatedefault: false,
persiststate: true,
toggleclass: ["", ""],
togglehtml: ["suffix", "<img src='images/plus.png' class='statusicon' />", "<img src='images/minus.png' class='statusicon' />"],
animatespeed: "fast",
oninit:function(headers, expandedindices){
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){
//do nothing
}
})
</script>
我也知道这是一个函数,但是我以前还从来没有见过这样的写法,里面参数冒号后面的是不是赋值啊
oninit:function(headers, expandedindices){
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){
//do nothing
}
{}配置对象写法,生成的是一个Object类型变量例如:
var obj={name:'name',value:'1',eat:function(){}};
等价于:
var obj=new Object();
obj.name='name';obj.value='1';obj.eat=function(){};{}里面配置了一个对象作为ddaccordion.init的参数,明白了么?
该方法肯定是在设计一个javascript插件,而这个函数就是为了初始化这个插件要使用的一些变量
好处主要是:可以统一化设置参数,代码看起来清爽!如果在插件各处都使用var定义一些变量的话,你会觉得代码没有逻辑性!
headerclass: "submenuheader", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click","clickgo", or "mouseover"
mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
animatedefault: false, //Should contents open by default be animated into view?
persiststate: true, //persist state of opened contents within browser session?
toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='images/plus.png' class='statusicon' />", "<img src='images/minus.png' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
//do nothing
},
onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
//do nothing
}
}ddaccordion.init(initObj);//
//就是这意思:当然,这个对象[ddaccordion]不是我定义的,如是我定义,绝对不会 这样搞初始化,(这样写的家伙,肯定没有学过代码优化的)