简体   繁体   English

jQuery删除元素上的包装,是否可能?

[英]jQuery removing wrapper on elements, is it possible?

I know it's a little hack but wondering if it is possible, I have the following markup (example) 我知道这有点黑客但想知道是否有可能,我有以下标记(示例)

<div class="homepage-boxes">

    <div class="row-fluid">
        <div class="span4"></div>
        <div class="span4"></div>
        <div class="span4"></div>
    </div>
    <div class="row-fluid">
        <div class="span4"></div>
        <div class="span4"></div>
        <div class="span4"></div>
    </div>

</div>

What I want to do is remove the 我想要做的是删除

<div class="row-fluid">

wrappers around the span4 containers so it will simply be span4容器周围的包装器就这么简单

<div class="homepage-boxes">
    <div class="span4"></div>
    <div class="span4"></div>
    <div class="span4"></div>
    <div class="span4"></div>
    <div class="span4"></div>
    <div class="span4"></div>
</div>

I can't really modify core files on this CMS as will cause issues with upgrades so going for a jQuery approach for a quick fixture until can decide how to action correctly so I know it's likely messy but it will only be for mobile. 我无法真正修改此CMS上的核心文件,因为这会导致升级问题,因此需要jQuery方法来快速固定,直到可以决定如何正确操作,所以我知道它可能很乱,但它只适用于移动设备。

Any ideas anyway? 反正有什么想法吗? I have had a look at .unwrap but did not have much luck with it 我看过.unwrap,但没有太多运气

您可以选择子元素,然后使用.unwrap()方法

$('.homepage-boxes .row-fluid').children().unwrap();

使用unwrap()方法: http//api.jquery.com/unwrap/

$('.span4').unwrap();

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

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