Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Show/Hide w jQuery
Meferot
post
Post #1





Grupa: Zarejestrowani
Postów: 64
Pomógł: 0
Dołączył: 31.08.2009

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


Jak przerobić ten skrypt:
  1. $('#show').click(function() {
  2. $('#register').show('fast');
  3. return false;
  4. });
  5. $('#hide').click(function() {
  6. $('#register').hide('fast');
  7. return false;
  8. });
  9. </script>

Tak żeby mógł obsługiwać wiele elementów?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
toaspzoo
post
Post #2





Grupa: Zarejestrowani
Postów: 778
Pomógł: 84
Dołączył: 29.07.2010
Skąd: Gliwice / Pławniowice Mistrz niezmordowanej klawiatury.

Ostrzeżenie: (20%)
X----


Kod

<script language="javascript">


var state = 'none';

function showhide(layer_ref) {

if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}

</script>


Potem tworzysz divy np:
  1. <div id="cos" style="display: none">tresc</div>
  2.  
  3. a potem w odnosniu <a href="#" onClick="showhide('cos');">Otworz!</a>












Go to the top of the page
+Quote Post

Posty w temacie


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: 5.10.2025 - 03:32