Loop through the links collection to set the onclick events for all of
the elements, like this:
<HTML>
<HEAD>
<TITLE></TITLE>
<script>
<!--
function setLinks() {
for(i=0; i<document.links.length; i++) {
document.links[i].onclick = myFunction;
}
}
function myFunction() {
alert("clicked");
}
//-->
</script>
</HEAD>
<BODY onload="setLinks()">
<a href="http://www.yahoo.com">Yahoo</a>
<a href="http://p2p.wrox.com">WROX</a>
<a href="http://www.excite.com">Excite</a>
</BODY>
</HTML>
> yes the function that handle you click could have a pointer on the
element
generating the event, so you can test anything you want, the class name,
the
value of a style, the parent node, the tag name...
Just handle this in the function called.
"payam." <torkian@c...> wrote in message
news:262129@j..._howto...
>
> thanks Fabrice,
> is it also possible to have same onClick results for tags in a specific
> class (or anything else)?
>
> for example have same onClick result for ANCHORS that are in a same
class:
>
> <STYLE>
> A.class1{COLOR:black;} ******just for these******
> </STYLE>
>
> <body>
> <a href=#>don't have onClick result</a>
> <a href=# class=class1>have onClick result</a>
> <a href=# class=class1>also have our onClick result</a>
> </body>
>
> thanks,
> payam
>
>
>
>