On Mar 4, 12:30 pm, dave <[EMAIL PROTECTED]> wrote:
> after creating an element how can I add a onMouseOver ?
>
> var mydiv = document.createElement('div');
> mydiv.innerHTML = "foo";
> mydiv.onMouseOver = "color=red";
Javascript object properties are case sensitive and event handlers
expect a function object, so:
mydiv.onmouseover = function(){this.style.color = 'red';}
...
// Don't allow circular references to presist
mydiv = null;
An alternative to the first line is to define the function elsewhere
and use a reference:
function setRed(){
this.style.color = 'red';
}
mydiv.onmouseover = setRed;
...
mydiv = null;
--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---