Hey everyone,

I'm wondering if this has already been thought of or not, but I have a
simple idea that could really improve dynamic creation of elements in

Here's the methods:

  build: function(element, type, options, style) {
    newElement = Element.build(type, options, style);
    return newElement;

Element.build = function(type, options, style)
  e = $(document.createElement(type));

  $H(options).each(function(pair) {
    eval("e." + pair.key + " = pair.value" );

  if (style) $H(style).each(function(pair) {
    eval("e.style." + pair.key + " = pair.value" );

  return e;


It changes this:

my_div = $(document.createElement("div"));
my_h1 = $(document.createElement("h1"));
my_h1.innerHTML = "Hello there!";
my_text = $(document.createElement("p"));
my_text.innerHTML = "Hello, here is some text";
my_text.style.fontSize = "25px";

into this:

my_div = Element.build("div");
my_div.build("h1", { innerHTML: "Hello there!" } );
my_div.build("p", { innerHTML: "Hello, here is some text" },
{ fontSize: "25px"});

Would such an enhancement be welcomed by the prototype core team?


You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to