2012-08-14 24 views
0

我試圖理解別人的代碼...他有如下:jQuery的位置片斷問題

var positionAt = horizontalPosition + ' ' + verticalPosition; 
    var positionOffset = String(horizontalOffset + ' ' + verticalOffset); 

    //i don't understand the codes below. I don't think Jquery position method support at and of attribues.... 

    $tooltipElement.position({at: positionAt, of: $element, my: 'left top', offset: positionOffset}); 

       $element.hover(function(){ 
          $instance = $(this).css({'cursor': 'pointer'}); 
          $('#tooltip-' + $instance.attr('id')).fadeIn('fast'); 
       }, function(){ 
          $instance = $(this).css({'cursor': 'auto'}); 
          $('#tooltip-' + $instance.attr('id')).fadeOut('fast'); 
       }); 

我不知道什麼與AT,和我的屬性位置的方法。任何人都可以幫助我嗎?非常感謝。

回答

1

他使用UI/Position plugin,其中定位功能需要myatof參數:

我:
該元素上的位置被定位對準 目標元素的定義: 「水平垂直」對齊。例如「right」的單個 值將默認爲「right center」,「top」將 默認爲「center top」(遵循CSS約定)。可接受的值: 「top」,「center」,「bottom」,「left」,「right」。例如:「左上」或 「中心中心」

於: 定義哪個目標元素來對齊靠在 定位元件上的位置:「水平垂直」對準。例如「right」的單個 值將默認爲「right center」,「top」將 默認爲「center top」(遵循CSS約定)。可接受的值: 「top」,「center」,「bottom」,「left」,「right」。例如:「左上」或 「中心中心」

元到針對位置。如果您提供選擇器,則將使用第一個匹配元素。如果您提供了一個jQuery對象,則將使用第一個元素。如果您提供事件對象,則將使用pageX 和pageY屬性。例如:「#top-menu」