Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] item.onclick = "alert('foo');";
- From: mdougherty at pbp.com (Mike Dougherty)
- Subject: [Javascript] item.onclick = "alert('foo');";
- Date: Mon Nov 7 09:54:58 2005
you are asking to have the alert() function evaluated and setting the result to the onclick method
of the "item" object variable. I think what you want to do is assign a function to that method,
like this: item.onclick = function(){ alert('foo'); }
ALSO:
function myfunction() { alert('foo'); }
item.onclick = myfunction; /* assign the function "myfunction" to the onclick method */
On Sun, 6 Nov 2005 15:01:34 -0800 (PST)
Anthony Ettinger <apwebdesign@xxxxxxxxx> 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@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
> __________________________________________________________
> This message was scanned by ATX
> 4:08:53 AM ET - 11/7/2005
- References:
- [Javascript] item.onclick = "alert('foo');";
- From: Anthony Ettinger
- [Javascript] item.onclick = "alert('foo');";
- Prev by Date: [Javascript] item.onclick = "alert('foo');";
- Next by Date: [Javascript] item.onclick = "alert('foo');";
- Previous by thread: [Javascript] item.onclick = "alert('foo');";
- Next by thread: [Javascript] item.onclick = "alert('foo');";
- Index(es):