Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [AJAX][JQUERY] hover i wykonywanie akcji
marian84
post 14.06.2012, 21:25:29
Post #1





Grupa: Zarejestrowani
Postów: 185
Pomógł: 10
Dołączył: 29.01.2008

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


Mam problem z hover dla jquery.
Problem polega na tym, że pierwsze najechanie na <li> nie wywoluje funkcji. Dopiero po drugim najechaniu funkcja raczy się wywołać

Kod
<script type="text/javascript">
        function pok(id)
        {
            var p = $("#li"+id);
            var str = $("#start_menu");
            var position = p.position();
            var positionS = str.position();
            var ods= position.left - positionS.left;
            var odleglosc="-"+ods+"px";
            $("#sub_"+id).css("margin-left", odleglosc);
            
            $("#li"+id).hover(
            function(){
                $("#a"+id).addClass("active2");
                $("#sub_"+id).fadeIn();
            },
            function(){
                $("#sub_"+id).fadeOut();
                $("#a"+id).removeClass("active2");
            });
        }
    </script>



Go to the top of the page
+Quote Post
kamil4u
post 14.06.2012, 21:38:25
Post #2





Grupa: Zarejestrowani
Postów: 2 350
Pomógł: 512
Dołączył: 4.01.2009
Skąd: Wrocław / Świdnica

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


Stwórz jakieś demo i nam pokaż jak to działa. Tylko jak najmniejszą ilość kodu proszę smile.gif


--------------------
Go to the top of the page
+Quote Post
marian84
post 14.06.2012, 22:04:42
Post #3





Grupa: Zarejestrowani
Postów: 185
Pomógł: 10
Dołączył: 29.01.2008

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


problem rozwiazany, dzieki za zainteresowanie

Ten post edytował marian84 14.06.2012, 22:43:57
Go to the top of the page
+Quote Post
kamil4u
post 14.06.2012, 23:14:45
Post #4





Grupa: Zarejestrowani
Postów: 2 350
Pomógł: 512
Dołączył: 4.01.2009
Skąd: Wrocław / Świdnica

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


Wypadałoby napisać co było nie tak i jak to naprawiłeś. Możliwe, że ktoś będzie miał podobny problem i Twój temat się komuś przyda.

Choć prawdopodobnie, zrobiłeś błąd( jakieś niedopatrzenie ) w innym miejscu( dlatego też prosiłem o demo )


--------------------
Go to the top of the page
+Quote Post
marian84
post 27.06.2012, 10:15:06
Post #5





Grupa: Zarejestrowani
Postów: 185
Pomógł: 10
Dołączył: 29.01.2008

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


Wywaliłem wywołanie funkcji dla li pok() (np <li onmouseover="pok(3)">slowo</li>) i dodałem wywolanie z jquery
Kod
<script type="text/javascript">
        $(document).ready(function(){
            $("li#li").hover(function(){
                $(this).children(".sub-links").fadeIn();
                
                var p = $(this);
                var str = $("#start_menu");
                var position = p.position();
                var positionS = str.position();
                var ods= position.left - positionS.left;
                var odleglosc="-"+ods+"px";
                $(this).children(".sub-links").css("margin-left", odleglosc);
                $(this).children("a").addClass("active2");
            },function(){
                $(this).children(".sub-links").fadeOut();
                $(this).children("a").removeClass("active2");
            });
        });
    </script>
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: 28.06.2025 - 22:58