Wrapping some html part with jQuery
I have 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>
As 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 with jQuery? Please help me with this.
+5
4 answers
read this link, this may help you: What is the most efficient way to create html elements with jquery
My answer is the answer, which will be as follows:
var myTimeIsHere = //calculate your time here;
var x = //calculate x here.;
var y = //calculate y here.;
var newHTML = "<span class='time'>" |+ myTimeIsHere+"</span>"+
"<div class='wrap'>To <strong> "+x+" </strong>"+
"by "+y+"</div>";
$(".the_notice").html(newHTML);
0