I would like to create element in Jquery/Javascript by using “div.someelement” like this
var SomeElement = $("div.someelement");
$( "#container" ).append( SomeElement );
But I don’t want to copy element with the same class, I would like to create new one.
document.createElement is creating "<div.somelement>" instead of <div class="someelement">
Try this:
This will create a brand new element inside of
#containerand save it as$someelementfor easy reference later.http://api.jquery.com/jQuery/#jQuery2
UPDATE
You could clone the original then empty it out. This doesn’t affect the original element at all.