试图让hide / show元素起作用 [英] Trying to get hide/show element to work

查看:67
本文介绍了试图让hide / show元素起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的javascript应该隐藏/显示div元素有些麻烦。我必须先点击链接两次才会隐藏。我似乎无法弄清楚为什么第一次点击什么都不做。

展开 | 选择 | Wrap | 行号

解决方案

展开 | 选择 | Wrap | 行号


< blockquote class =post_quotes>
尝试提醒 which.style.display 的初始值。



我添加了alert(which.style.display);到功能的开头。


我第一次点击它时,警报中没有任何内容。第二次说阻止。



我添加了alert(which.style.display);到功能的开头。


我第一次点击它时,警报中没有任何内容。第二次说阻止。



似乎第一次点击,没有任何东西被传递给函数,但是第二次传递给函数。


I''m having some trouble with my javascript which is supposed to hide/show a div element. I have to click on the link twice before it''ll hide. I can''t seem to figure out why the first click does nothing.

Expand|Select|Wrap|Line Numbers

解决方案

Expand|Select|Wrap|Line Numbers


Try alerting the initial value of which.style.display.

I added alert(which.style.display); to the beginning of the function.

The first time I click it, there''s nothing in the alert. The second time it says block.


I added alert(which.style.display); to the beginning of the function.

The first time I click it, there''s nothing in the alert. The second time it says block.

It seems that the first time I click, nothing is being passed to the function, but the second time it is.


这篇关于试图让hide / show元素起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆