Hi,
as you know, if I attach a property to the object prototype, it will be attached to all objects from the same instance.
example :
if I have a couple of images inside a document such as :
<img src=""/>
<img src=""/>
<img src=""/>
I can say : document.images[0].prototype.prin tMessage = myFunction ;
where is :
function myFunction(){ alert('Hello'); }
now if I call : document.images[0].printMessage() , also
document.images[1].printMessage() , ... all of them will alert "Hello".
the question :
if I have a couple of anchors inside a document, can I say :
document.links[0].prototype.oncl ick = myFunction;
such as when I click on that anchor by the mouse, the function would be called ? .
thanks
as you know, if I attach a property to the object prototype, it will be attached to all objects from the same instance.
example :
if I have a couple of images inside a document such as :
<img src=""/>
<img src=""/>
<img src=""/>
I can say : document.images[0].prototype.prin tMessage = myFunction ;
where is :
function myFunction(){ alert('Hello'); }
now if I call : document.images[0].printMessage() , also
document.images[1].printMessage() , ... all of them will alert "Hello".
the question :
if I have a couple of anchors inside a document, can I say :
document.links[0].prototype.oncl ick = myFunction;
such as when I click on that anchor by the mouse, the function would be called ? .
thanks
Comment