Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript][HTML]Rozwijane/chowane divy
Skicek
post 15.10.2011, 20:55:04
Post #1





Grupa: Zarejestrowani
Postów: 30
Pomógł: 0
Dołączył: 19.09.2011

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


Witam,
mam problem z chowaniem diva gdy drugi sie rozwija. Mianowicie uzywam biblioteki jquerty i funkcji slidetoggle

CODE

$(document).ready(function() {
$('.chowaj').click(function () {
var xyz = $(this).attr('href');
$(xyz).slideToggle('normal');
return false;
});
});


CODE
<a href="#id1" class="chowaj">111</a><a href="#id2" class="chowaj">2222</a><a href="#id3" class="chowaj">333</a><a href="#id4" class="chowaj">444</a>
<div id="id1" style="display:none;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>

<div id="id2" style="display:none;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>

<div id="id3" style="display:none;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>

<div id="id3" style="display:none;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>



a chodzi mi o cos podobnego do tego http://pliki.vivee.info/demo/slide/4.html tylko z tym ze nie typu akordeonowego tylko Guziki jeden obok drugiego a pod nimi wyswietla sie zawartosc ich i chowa gdy wcisnie sie nastepny (oczywiscie zawartosc nastepnego sie pojawia)
Go to the top of the page
+Quote Post
konrados
post 15.10.2011, 21:06:07
Post #2





Grupa: Zarejestrowani
Postów: 623
Pomógł: 79
Dołączył: 16.01.2008

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


A coś takiego: http://jqueryui.com/demos/tabs/ ?
Tyle, że 'tabs' (czyli te "guziki") umieścisz sobie na dole.
Go to the top of the page
+Quote Post
Skicek
post 15.10.2011, 21:09:58
Post #3





Grupa: Zarejestrowani
Postów: 30
Pomógł: 0
Dołączył: 19.09.2011

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


"guziki" sa latwiejsze do zrobienia jesli nie znajde rozwiazania jak zrobic "rozwijane" to to bede musial uzyc tabsow.

Choc przyznam ze bardziej interesuje mnie slidetoggle tylko z opcja by poprzednik sie chowal.
Go to the top of the page
+Quote Post
konrados
post 15.10.2011, 21:15:32
Post #4





Grupa: Zarejestrowani
Postów: 623
Pomógł: 79
Dołączył: 16.01.2008

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


To może spróbuj tak:

  1. <div id="id1" style="display:none;" class = 'tab_content'>


Jak widzisz, dołożyłem klasę 'tab_content' i teraz:

  1. $('.chowaj').click(function () {
  2. $('.tab_content').hide();//ukrywamy wstępnie wszystkie
  3. var xyz = $(this).attr('href');
  4. $(xyz).slideToggle('normal');
  5. return false;
  6. });
Go to the top of the page
+Quote Post
Skicek
post 15.10.2011, 21:23:47
Post #5





Grupa: Zarejestrowani
Postów: 30
Pomógł: 0
Dołączył: 19.09.2011

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


nie zadziałało, niestety


edit:

tzn zadzialalo ale dziala strasznie topornie... w sensie rozwija sie plytnie a chowa sie w ulamek sekundy


edit 2:

dobra po prawilem juz po swojemu czyli wystarczylo dac argument czasowy "hide'owi" i dziala. Moze nie wyglada to super zajebiscie ale przelatujace literki tez sa super ;D

thx konrados

Ten post edytował Skicek 15.10.2011, 21:30:14
Go to the top of the page
+Quote Post
konrados
post 15.10.2011, 21:31:51
Post #6





Grupa: Zarejestrowani
Postów: 623
Pomógł: 79
Dołączył: 16.01.2008

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


Ależ proszę.
Możesz też się bawić w funk. slideUp etc.
Go to the top of the page
+Quote Post
-gosc-
post 15.10.2011, 21:32:23
Post #7





Goście







tak jak napisal konrados dodaj wszystkim divom klasę class=tab_content

  1. $('.chowaj').click(function () {
  2. $('.tab_content').slideUp();
  3. var xyz = $(this).attr('href');
  4. $(xyz).slideDown('normal');
  5. return false;
  6. });
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 02:35