create if conditional based on css properties
This question already has an answer here:
This is a way to determine it for all css properties including visibility: this works for properties set in a external css file, internal embedded styles, or inline styles! Note: the document MUST be loaded before executing the script!
I have tested this out and it works with css rules set in inline, embedded, and external.
html:
<div id="element" onload="test();">div content</div>
css:
#element
{
visibility:hidden;
}
javascript:
function test()
{
var element = document.getElementById('element');
if(element.style.visibility == 'hidden'){
alert('hidden');
}
if(element.style.visibility == 'visible')
{
alert('visible');
{
if(element.style.visibility == 'collapse')
{
alert('collapsed');
}
if(element.style.visibility == 'initial')
{
alert('initial');
}
if(element.style.visibility == 'inherit')
{
alert('inherit');
}
}
I have used this before.
链接地址: http://www.djcxy.com/p/83570.html下一篇: 根据CSS属性创建条件