2012-03-04 58 views
0

我想愛上與jQuery UI的定位功能,但每次我運行附件的代碼中,我得到的JavaScript控制檯以下錯誤:錯誤:對象有沒有方法「分裂」

firefox: (b[this] || "").split is not a function
chromium: Uncaught TypeError: Object [object Object] has no method 'split'

我下載完整的jQuery UI包,幷包括CSS,jQuery-min和jQuery-UI-min。

不知道如果我只是用它錯了,錯過了一個簡單的事情踢魔術。我試圖模仿the example from the project webpage:C至少我希望目前的版本不破:C

<html> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 

    <link rel="styleSheet" type="text/css" href="jquery-ui-1.8.18.custom.css" /> 

    <script type="text/javascript" src="jquery-1.7.1.min.js"></script> 
    <script type="text/javascript" src="jquery-ui-1.8.18.custom.min.js"></script> 

    <script type="text/javascript"> 
     $(function() { 

     function position(using) { 

      $("#main").position({ 
       of: $("#head"), 
       my: $("right top"), 
       at: $("right bottom") 
      }); 
     } 

     position(); 
    }); 
    </script> 
    </head> 

    <body> 
    <div id="head" style="background-color: #F21; height: 7%"> 
     Menu 
    </div> 

    <div id="main" style="background-color: #1A9; width: 50%; height: 50%; position: absolute"> 
     <h1>Jules Verne</h1> 
    </div> 
    </body> 
</html> 

回答

4

你傳遞了​​錯誤的參數,以「我」和「AT」。你只需要傳遞一個字符串,而不是一個jQuery對象。像這樣做,而不是:

$("#main").position({ 
    of: $("#head"), 
    my: "right top", 
    at: "right bottom" 
}); 

jsFiddle example

(更新代碼和jsfiddle來匹配問題編輯)

+0

+1並接受(在5分鐘內......)並且非常感謝。我現在覺得自己很有幫助http://i2.listal.com/image/3170280/500full.jpg非常感謝您的幫助! ^^ v – yoshi 2012-03-04 01:55:06

+0

;)沒問題。發生在我們所有人身上。很高興我能幫上忙。 – j08691 2012-03-04 01:56:16

+0

只是說:不知道「中間」是否是一個有效的值,雖然它似乎工作它沒有真正記錄在頁面上。只需在源代碼中使用2次即可。小心! :) – yoshi 2012-03-04 01:58:58

相關問題