Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript]Menu kontekstowe i position top
Maxie
post
Post #1





Grupa: Zarejestrowani
Postów: 82
Pomógł: 1
Dołączył: 19.10.2011

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


Witam. Napisałem prosty plug-in w JQuery i mam malutki problem smile.gif . Otóż nie wiem jak określić właściwość "top" w css rzecz jasna za pomocą JQuery.
Kod wygląda następująco:
Kod
hook = '.menu';
button = '.btn';

$('ul' + hook).each( function(){
$(this).hide();
});

$(button).click( function(){
  button = $(this);
    $('ul' + hook).each( function(){
      if(button.attr('name') == $(this).attr('name')){
        position = $(button).offset();
        left = position.left + button.outerWidth() - $(this).outerWidth();
        top = position.top + button.outerHeight() - $(this).outerHeight();
        
        if(button.attr('menu-position') == 'right'){
          left = position.left;
          top = position.top + button.outerHeight();
        }
        
        if(button.attr('menu-position') == 'left'){
          left = position.left + button.outerWidth() - $(this).outerWidth();
          top = position.top + button.outerHeight() - $(this).outerHeight();
        }
        
        if(button.attr('menu-position') == 'center'){
          half = $(this).outerWidth() / 2;
          halftwo = button.outerWidth() / 2;
          left = position.left - half + halftwo;
          top = position.top + button.outerHeight() - $(this).outerHeight();
        }
        
        $(this).css("top", top);
        $(this).css("left", left);
      if($(this).is(':hidden')){
       $(this).show();
      }else{
        $(this).hide();
      }
      }
    });
});

Otóż 'left' jest określany prawidłowo, a 'top' w ogóle nie jest określany. Powiedzcie co robię nie tak. Z góry dzięki za pomoc!
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 Aktualny czas: 20.08.2025 - 06:25