Running as re-usable code.

Running as re-usable code.

Can you tell me how I can get this piece of code to run when the link is pressed on both pages:


I know I could do it with the following:

  1. $("#"+a0+" .btnCode").click(function(){
  2. alert("I've been pressed From: "+a0+" - "+$(this).attr("href"));
  3. });
  4. $(".btnCode").click(function(){
  5. alert("I've been pressed From: "+a0+" - "+$(this).attr("href"));
  6. });

But as this is used many times I thought it might be easier using something like the former.

Many thanks.