When you create an element with "new Element()", it only exists as a
javascript variable until you append the element to the DOM.

The $() function looks in the DOM for the element, which is why it is not
finding it.

Also, you may want to use Element#setStyle() instead of accessing the style
property directly. It's much more consistent cross-browser.

var a = new Element('div', {id: 'my_div'});
a.setStyle({width: '200px'});


-Hector


On Fri, Nov 21, 2008 at 11:35 AM, chrissu13 <[EMAIL PROTECTED]> wrote:

>
> What do I make wrong that Firebug gives me a "$("my_div") is null"
> Error-Message when debugging the following lines?
>
> Chrissu
>
> ------
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <script type="text/javascript" src="LIB/prototype.js"></script>
> <title>test</title>
> <script>
> var a = new Element('div', {id: 'my_div'});
> $('my_div').style.witdh = '200px';
> </script>
> </head>
> <body>
> </body>
> </html>
> ---------
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to