You could add a javascript function that takes a single argument, an id or whatever you prefer, and then add an onclick to all elements you are interested in that calls this function:
<html>
<head>
<title>Click test</title>
<script type="text/javascript">
function myClickHandler(elm)
{
alert('' + elm + ' element clicked');
}
</script>
</head>
<body>
<h1 onclick="myClickHandler('first');">First element</h1>
<h1 onclick="myClickHandler('second');">Second element</h1>
</body>
</html>
Edit: Ooh - you re not looking for a html/javascript solution. sorry.