Reputation: 2462
I've seen such a thing before and I forgot to bookmark it. It was a plugin for something, wish I knew what was it for to keep searching.
Anyway I need to learn how to create a HTML structure within jQuery using array. I remember that guy who made a plugin that I've seen have used following:
var struct = [];
.join(), .pop(), .push()
I tried these but I can't figureout how to create such a thing and append it into body. I always create a default structure like this.
$("body").append(//->
'<div class="daBox-outer">' +
'<div class="daBox-inner">' +
'<div class="daBox-top" />' +
'<div class="daBox-bottom" />' +
'</div>' +
'<div class="daBox-overlay" />' +
'</div>'
//<-
);
Please if anyone know how to make such a structure using array, let me know with an example! Link redirect to any plugin that has structure made with jQuery arrays is also welcome, so I can learn out of it.
Upvotes: 1
Views: 1298
Reputation: 131
Is this what you had in mind?
var structure = [];
var mydiv = document.createElement("div");
mydiv.className="myClass";
structure.push(mydiv);
//then all you need to do
$("body").append(structure);
What it does: It creates new element div it adds the div to the array finally it appends it you can do the document.body.appendChild if you want to go through pure js. You can view this jsfiddle - Click!
Upvotes: 2