Aaron
Junior Member
And what is Fonzie like?
Posts: 265
inherit
25673
0
Mar 10, 2013 19:53:10 GMT -8
Aaron
And what is Fonzie like?
265
June 2004
derfleurer
|
Post by Aaron on Jun 12, 2007 19:31:25 GMT -8
Open source JavaScript function.
Description: Allows you to create an element and assign it several attributes at once. I'll probably rewrite this later. Could come in handy working with objects in general.
Syntax: createElement(string, {parameters})
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; }
Example: (added the line-breaks so it'd be easier to see)
var i = createElement("td", { width: "100%", height: 200, colSpan: 2, className: "menubg", style: { color: "#FFFFFF", backgroundColor: "#000000" } });
|
|
ungoliant
inherit
-167316
0
May 18, 2024 8:56:32 GMT -8
ungoliant
0
January 1970
GUEST
|
Post by ungoliant on Jun 13, 2007 3:46:19 GMT -8
um...shouldnt you be posting this in the code snippets?
|
|
Aaron
Junior Member
And what is Fonzie like?
Posts: 265
inherit
25673
0
Mar 10, 2013 19:53:10 GMT -8
Aaron
And what is Fonzie like?
265
June 2004
derfleurer
|
Post by Aaron on Jun 13, 2007 6:52:19 GMT -8
|
|
inherit
68695
0
Jan 20, 2021 21:20:26 GMT -8
Jake
1,291
January 2006
liquidsword
|
Post by Jake on Jun 13, 2007 7:10:55 GMT -8
Hey Aaron, sorry but I don't gets it.. =]
|
|
inherit
Official Code helper
60405
0
Feb 18, 2012 23:45:36 GMT -8
(¯`•DregondRahl•._)
Set~[Me]~Free
6,637
October 2005
dregondrahl
|
Post by (¯`•DregondRahl•._) on Jun 13, 2007 7:16:15 GMT -8
Added
|
|
Aaron
Junior Member
And what is Fonzie like?
Posts: 265
inherit
25673
0
Mar 10, 2013 19:53:10 GMT -8
Aaron
And what is Fonzie like?
265
June 2004
derfleurer
|
Post by Aaron on Jun 13, 2007 7:17:57 GMT -8
You're too good to me.
Well, it's not a code for a forum or anything, it's just a snippet to make a coder's work easier.
Basically, in the same way you'd do:
var i = document.createElement("td"); i.width = "100%"; i.height = "200"; i.colSpan = "2"; ...
You could just do:
createElement("td", { width: "100%", height: 200, colSpan: 2 })
If you're unfamiliar with the { : syntax, google "JSON."
|
|