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 - CUDA code not processing if block properly -

oracle11g - get root domain from url Oracle sql regex_substr -

xcode - Swift Playground - Files are not readable -