Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrapping some part of html using jQuery

I've something like:

<div class="the_notice">
    <span class="time"> | 3:48pm</span>
    To <strong>2013-03-16_10-56-33</strong> By <strong>XYX</strong>
</div>

In a result I want something like:

<div class="the_notice">
    <span class="time"> | 3:48pm</span>
    <div class="wrap">
      To <strong>2013-03-16_10-56-33</strong> By <strong>XYX</strong>
    </div>
</div>

How can I achieve this using jQuery? Please help me on that.

like image 562
The System Restart Avatar asked Apr 02 '13 11:04

The System Restart


1 Answers

Well if the contents will always be the same, you can do something like

$('.the_notice').contents().slice(2).wrapAll('<div class="wrap"/>');

http://jsfiddle.net/Ysq48/

like image 171
epascarello Avatar answered Sep 25 '22 23:09

epascarello