admin管理员组文章数量:1334342
I have a DIV that is set do display:none from CSS and it's supposed to be made visible (style.display = '';
) at some point by javascript.
The problem is that if I put the display:none
in the CSS file the javascript does not seem to have any effect. I have also tried changing the background color instead of the display property, and that works.
I have the code running here (just press the edit link).
I really thank you for taking the time to look into this.
I have a DIV that is set do display:none from CSS and it's supposed to be made visible (style.display = '';
) at some point by javascript.
The problem is that if I put the display:none
in the CSS file the javascript does not seem to have any effect. I have also tried changing the background color instead of the display property, and that works.
I have the code running here (just press the edit link).
I really thank you for taking the time to look into this.
Share Improve this question edited Jan 1, 2011 at 23:46 jball 25k9 gold badges72 silver badges92 bronze badges asked Jan 1, 2011 at 23:33 Sorin ButurugeanuSorin Buturugeanu 1,1227 gold badges13 silver badges19 bronze badges3 Answers
Reset to default 5Set it to block
or inline
using Javascript.
Writing style.display = ""
will clear any display
set in the inline style, and cause it to revert to whatever it inherited from CSS.
Alternatively, you can change the element's className
using Javascript so that the CSS rule no longer applies.
This is because style.display = ''
only affects inline styles on an element. It doesn't change the style sheet.
You should set it to whatever display
you need:
style.display = 'block';
or add a class that represents the style you want.
other way to hide content is use opacity=0
and to again make visible
use opacity=1
thats it....!!!
本文标签: Javascript won39t overwrite CSS display propertyStack Overflow
版权声明:本文标题:Javascript won't overwrite CSS display property - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742369191a2461890.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论