2012-02-26 18 views
0

我的代碼不工作。 我想使用warpAll()在div id =「wrap_all」和他的子女 周圍創建邊框。 難道可以使用$("#wrap_all").wrapAll("<div></div>"); 如果是,我不知道如何。 我allso不知道如何將​​內("<div id="xxx"></div>") 爲了操縱id爲XXX的新div來使創建邊界div和他的孩子使用wrapAll

$(#'xxx')..css("border", "3px double red"); 

鏈接examle:http://jsfiddle.net/centerwow/9TPtn/27/ 感謝。

代碼的html:

<div class="foo">a</div> 
<div class="foo">b</div> 
<div class="foo">c</div> 
<div id="foo" class="foo">d</div> 
<div id ="wrap_all"> 
    <div class="foo">r</div> 
    <div class="foo">f</div> 
    <div class="foo">g</div> 
</div> 
<div class="foo">h</div> 
<span></span>​ 

鏈接examle。

jQuery代碼:

var modWidth = 50; 
$('#wrap_all').hover(function() { 
    $(this).warpAll() 
    $(this).css("background", "green"); 
    $(this).css("border", "3px double red"); 
    $(this).width(modWidth); 


}, function() { 
     $(this).css("background", "#cac"); 
     $(this).width(40); 
    }); 
+0

在解決問題時,您應該接受問題的答案。沒有被接受的答案不好。 – Ryan 2012-02-26 19:44:53

回答

0

不知道這是否是問題,但你發佈的代碼表示

$(this).warpAll() 

而不是

$(this).wrapAll(); 

(注意的正確拼寫「換行」和添加的分號)。