Dojo切换隐藏并显示Divs [英] Dojo Toggle Hide and Show Divs
本文介绍了Dojo切换隐藏并显示Divs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经做了一些搜索,并提出了很多混合的结果,使用Dojo来切换显示vs隐藏的div。
I've done some searching and come up with a lot of mixed results for using Dojo to toggle divs showing vs hidden.
- 有些使用
dojo.style
它看起来可能已被dojo.fx
- 有些使用
dijit
,因此无法访问DOM节点。 - 有些使用
show ()
和hide()
- 有些更改CSS
- Some use
dojo.style
which it looks like might have been replaced bydojo.fx
- Some use
dijit
but thus cannot access a DOM node. - Some make use of
show()
andhide()
- Some change the CSS
我似乎无法让任何人上班。
I can't seem to get any of them to work.
有人可以指点我
已解决
使用以下组合...
dojo.addOnLoad(function() {
dojo.style(dojo.byId('myDiv'), "display", "none");
});
并切换
function toggleDivs(){
if( dojo.style(dojo.byId('myDiv'), "display") == "none"){
dojo.style(dojo.byId('myDiv'), "display", "block");
dojo.style(dojo.byId('myDiv2'), "display", "none");
} else {
dojo.style(dojo.byId('myDiv'), "display", "none");
dojo.style(dojo.byId('myDiv2'), "display", "block");
}
}
推荐答案
为什么不要使用 dojo.fx.Toggler
?
var toggler = new dojo.fx.Toggler({
node: "basicNode"
});
dojo.connect(dijit.byId("showButton"), "onClick", toggler, "show");
dojo.connect(dijit.byId("hideButton"), "onClick", toggler, "hide");
}`
从dojo 参考指南:
功能Toggler.show()和Toggler.hide()都返回动画的动画对象。该对象可用于停止,暂停,设置当前动画位置'百分比',并获取动画状态。
The functions Toggler.show() and Toggler.hide() both return the animation object for the animation in play. This object can be used to stop, pause, set the current animation location ‘percentage’, and get the status of the animation.
这篇关于Dojo切换隐藏并显示Divs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文