Identify visible element [duplicate]

0

My problem is that I need a property or something to be able to know if an element (div) is visible in the scroll window and in the same way is not hidden

    
asked by Ale Rodriguez 27.09.2018 в 07:32
source

2 answers

0

Being 'testdiv' the element you want to consult you can check its visibility from javascript using:

document.getElementById('testdiv').style.visibility.

Greetings.

    
answered by 27.09.2018 в 08:07
0

Check that your div has a id or a class and do this check (you need javascript)

<div id="contenedor"></div>

<script type="text/javascript">
    if ($("div#contenedor").css('display') == 'none' || 
        $("div#contenedor").css("visibility") == "hidden"){
        // El div no se muestra en pantalla
    } else {
        // El div se muestra en pantalla
    }
</script>

With class it would be the same but with a period - div.contenedor

    
answered by 27.09.2018 в 08:21