I am trying to find a solution to open one div
by clicking a link, and close/toggle all other open div
s at the same time.
This is my code: http://jsfiddle.net/6Ptkw/1/
I thought this was the right way, but it doesn't work.
I am trying to find a solution to open one div
by clicking a link, and close/toggle all other open div
s at the same time.
This is my code: http://jsfiddle.net/6Ptkw/1/
I thought this was the right way, but it doesn't work.
您可以尝试此代码(只需将其应用于您的元素)此“幻灯片打开”一个 div 元素:
$('#workload').click(function(){
$('#work').load('pagehere.jsp');
$('#work').animate({
height: '25%',
fontSize: "3em",
borderWidth: "10px"
}, 1000 ); });
只需使用 .hide() 函数隐藏其他元素。:) 希望这个对你有帮助!
您很接近,但请注意,jsfiddle 默认情况下将所有内容包装在 onDomReady 函数闭包中,这意味着您的 slideonlyone 函数不再可见。
你发布的 jsFiddle 会有这样的代码
$(function(){
function slideonlyone(){
//your code
};
});
一个该onDomReady
函数退出,您将不再有任何引用该slideonlyone
函数的范围
我将其更改为 nowrapper,以便它可以在全局范围内使用。这通常是不好的做法,您应该通过以下方式附加点击事件
$("a").click(function(){
})
而不是做<a href="javascript:">