Reputation: 761
I want to wrap a link which is in a div:
This :
<div id="hello">
http://google.fr/646564897564/8977748946
</div>
will be:
<div id="hello">
<div id="wrap">
http://google.fr/646564897564/8977748946
</div>
</div>
Upvotes: 0
Views: 62
Reputation: 41605
Making use of jQuery you can use the wrapInner function:
var outer = $("#hello");
outer.wrapInner('<div id="wrap">);
Upvotes: 3
Reputation: 17927
have a look here: http://jsfiddle.net/R44pn/
JS
var outer = document.getElementById("hello");
outer.innerHTML = "<div id='wrap'>"+outer.innerHTML+"</div>"
OUTPUT
<div id="hello">
<div id="wrap">
http://google.fr/646564897564/8977748946
</div>
</div>
with JQuery
$("#hello").html("<div id='wrap'>"+$("#hello").html()+"</div>")
fiddle here: http://jsfiddle.net/q27Sw/
hope it helps
Upvotes: 3