html - create if conditional based on css properties -- javascript -


this question has answer here:

how find if css properties set in way? example how find if element has css property of background-color:#ff0000;? or if element has width etc...

this way determine css properties including visibility: works properties set in external css file, internal embedded styles, or inline styles! note: document must loaded before executing script!

i have tested out , works css rules set in inline, embedded, , 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 before.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -