Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Visibility
Rawler
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 8.10.2011

Ostrzeżenie: (0%)
-----


Witam,
Jestem początkującym w javascript i mam pytanie.

  1. <div id="alert" style="visibility:visible;">


Jaką komendą sprawdzić visibility czy jest 'visible' czy 'hidden'?

Pozdrawiam,
Rawler
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Damonsson
post
Post #2





Grupa: Zarejestrowani
Postów: 2 355
Pomógł: 533
Dołączył: 15.01.2010
Skąd: Bydgoszcz

Ostrzeżenie: (0%)
-----


[JAVASCRIPT] pobierz, plaintext
  1. if(document.getElementById('alert').currentStyle.visibility == 'visible') alert('visible');
  2. else alert('hidden');
[JAVASCRIPT] pobierz, plaintext


Również serdecznie pozdrawiam (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post
acidm
post
Post #3





Grupa: Zarejestrowani
Postów: 110
Pomógł: 3
Dołączył: 12.03.2011
Skąd: Opole

Ostrzeżenie: (0%)
-----


można w tym przypadku poprzez pole style elementu:
Kod
    if(document.getElementById('alert').style.visibility==='visible'){alert('visible')}
else {alert('hidden')}


lub tak jak odczytuje styl przeglądarka (pole currentStyle nie we wszystkich jest dostępne):

Kod
function getCss(obiekt, wlasnosc) {
        if (obiekt.currentStyle) {
            return obiekt.currentStyle[wlasnosc];
        } else if (window.getComputedStyle) {
            return document.defaultView.getComputedStyle(obiekt, null)[wlasnosc];
        }
    }
    
    if(getCss(document.getElementById('alert'),'visibility')==='visible'){alert('visible')}
else{alert('hidden')}


Ten post edytował acidm 9.10.2011, 17:30:05
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 14:45