0

I have this:

    <div class="to_remove">
    <div class="widget widget-list">
    <div class="panel panel-default">
    <div class="panel-heading bold">Menu</div>
    <div class="panel-body">
      content
    </div>
    </div>
    </div>
  </div>

I need preg_replace to edit like this:

        <div class="widget widget-list">
        <div class="panel panel-default">
        <div class="panel-heading bold">Menu</div>
        <div class="panel-body">
          content
        </div>
        </div>
    </div> 

I need to remove <div class="to_remove"></div> but the content between tags must be stay.

3
Contributors
3
Replies
23
Views
1 Year
Discussion Span
Last Post by Ivan_10
0

In your example you open 5 – five divs (you have five <div>) and you close 4- four divs (you have </div>), what exactly is it ? . If it were all nice and clean its quite simple:

Html:

    <div class="to_remove">
        <div class="widget widget-list">
            <div class="panel panel-default">
                <div class="panel-heading bold">Menu</div>
                    <div class="panel-body">
                    content
                    </div>
                </div>
            </div>
        </div>
    </div>  

JavaScript:

        var $children = $(".to_remove").children();
        $children.insertBefore(".to_remove");
        $(".to_remove").remove();

I don't think that I should also point the inconsistency in css class names (e.g. - in widget-list but _ in to_remove also it is a panel why should be “panel panel-default” and not just “panel default” ?)

Edited by jkon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.