2012-03-04 54 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

相关问题