This is a snippet
This is a function that will allow you to create an element and assign attributes without having to go through lines and lines of coding!
function create(x, y) {
if(x.constructor == String){
x = document.createElement(x);
}
for(var a in y) {
if(y[a].constructor == Object) {
this.create(x[a], y[a]);
continue;
}
x[a] = y[a];
}
return x;
};
Example of usage:
Creating a td
create('td',{colSpan: "2", vAlign: "top"});
That has Colspan of 2 and valign top.
create('div',{style: {backgroundColor: "#FF0000"}, align: "center"});
You get the idea!
I get the Idea however I would Really like to know Where to Put it at? Header,footer,Global or Main?
Thanks
Flash
It's a 'snippet' really that a coder would use in their codes!
Code:
- function createElement(a, b) {
- if(a.constructor == String)
- a = document.createElement(a);
- for(var x in b) {
- if(b[x].constructor == Object) {
- createElement(a[x], b[x]);
- continue;
- }
- a[x] = b[x];
- }
- return a;
- }
http://forum.smangii.com/index.cgi?board=pbsupport&action=display&thread=6636&page=1#67534
This code is exactly the same as that, except a few changed variable names. Rip?
So someone's not allowed to read a code - and then recode it?
*sigh* if that's what someone isn't allowed to do!
So someone's not allowed to read a code - and then recode it?
*sigh* if that's what someone isn't allowed to do!
Copying a code and changing a few variable names is not taking inspiration from something, its stealing it.