Connecting Tech Pros Worldwide Forums | Help | Site Map

setting onclick attributes of a createelement created element

libsfan01
Guest
 
Posts: n/a
#1: Aug 21 '06
hi how can u set the onclick attributes of a 'createelement' created
element? such as giving it an onclick event?

regards

Marc


web.dev
Guest
 
Posts: n/a
#2: Aug 21 '06

re: setting onclick attributes of a createelement created element



libsfan01 wrote:
Quote:
hi how can u set the onclick attributes of a 'createelement' created
element? such as giving it an onclick event?
>
regards
>
Marc
There are several ways of doing what you want.

For example, here's one way:

function foo()
{
}

var elem = document.createElement("DIV");
elem.onclick = foo;

Closed Thread