[Javascript] item.onclick = "alert('foo');";
Judah Frangipane
judah-fc at t8design.com
Mon Nov 7 10:15:57 CST 2005
Hi Anthony,
Try something like this,
var item = document.getElementById('foo');
item.onclick = function () {
alert('foo');
}
on click in javascript may be case sensitive, ie "onClick"
the way you have it you are only passing in a string and not a reference
to the alert function
to do it your way you have to do this
// assign onclick equal to the alert function
item.onClick = alert;
item.onClick("some value")
but since alert takes a parameter i do not know if it will work. i do
not know if onClick passes in an evt object so you may have to stick
with the first example i gave you.
Judah
Anthony Ettinger wrote:
>this doesn't seem to work:
>
>var item = document.getElementById('foo');
>item.onclick = "alert('foo');";
>
>http://developer.mozilla.org/en/docs/DOM:element.onclick
>
>Anthony Ettinger
>ph: (408) 656-2473
>web: http://www.apwebdesign.com
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>
>
>
More information about the Javascript
mailing list