繁体   English   中英

使用wrapAll在div和他的孩子周围创建边框

[英]create border around div and his children using wrapAll

我的代码无法正常运行。 我想使用warpAll()在div id =“ wrap_all”及其子项周围创建边框。 是否可以和$("#wrap_all").wrapAll("<div></div>"); 如果是的话,我不知道该怎么做。 我还不知道如何在id="xxx" ("<div id="xxx"></div>")顺序("<div id="xxx"></div>")

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

例如的链接: 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>​

链接示例。

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);
    });

不知道这是否是问题,但是您发布的代码说

$(this).warpAll()

代替

$(this).wrapAll();

(请注意,“ wrap”的正确拼写和添加的分号)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM