2010-06-04 68 views
1

我有以下代码:jQuery的包裹迫使多个文档准备回调

function CreateRoundbox(selector, scope) { 
    $(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>'); 
    $('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>'); 
} 

每当我用这个功能和“包装”的方法被调用时造成的$(document)。就绪()方法在页面上再次点燃。下面是对函数的调用(它生活在一个文档就绪区块中):

CreateRoundbox(".roundbox", "roundbox-wrapper");  

有没有人遇到过这个?我使用换行错了吗?

UPDATE

固定的使用习惯,我不小心在范围文本增加了一个点

+0

我很困惑,为什么都“逃脱 – Zuul 2010-06-04 01:47:09

+0

@ Zuul - ?哈哈...他就像这样我猜...但这不是问题..是吗?..) – Reigel 2010-06-04 01:51:21

+0

@Reigel,哈哈... nopes,但我只是看着它,无法把握我的头; ) – Zuul 2010-06-04 01:56:07

回答

0
function CreateRoundbox(selector, scope) { 
          //   v----> this will result to class=".roundbox-wrapper", which is, I guess, not the thing you want in there.. :) 
    $(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>'); 
    $('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>'); 
    // ^^
    //  | |--- look at scope.... then, look here at the second argument, CreateRoundbox(".roundbox", ".roundbox-wrapper"); 
    //  |--- look at the dot.... :) CreateRoundbox(".roundbox", ".roundbox-wrapper"); 

} 
+0

我明白你在说什么......我会更新上面的例子......我只是输入了用法,并把它搞砸了;) – 2010-06-04 02:17:54

+0

哈哈带着倒票......我希望至少有理由被解释... ...为进一步增强答案..;) – Reigel 2010-06-04 02:37:07

+0

是的,因为它对实际答案没有影响(我留下了一个解释的评论,更不用说更新问题了)。如果这是问题的答案,它会得到赞扬。合理? – 2010-06-04 02:47:59