Need to add an element in a web page, cloning the actual.
console.log(($this));
Gives something like this:
<div id="id" class="class" style="style">
<p style="style">World</p>
</div>
I want to add word “Hello” with the exact same structure, before “World”
Tried with attr() or html() but replaces all the attributes.
This will do it for only one DIV with that particular ID (Id]s are unique)
Sample : http://jsfiddle.net/trdxg/2/
If you want to do it for n number of elements with same structure, you can change your jQuery selector to use the
class.Sample : http://jsfiddle.net/trdxg/7/