It seems like the standard pattern for calling a JavaScript function when text is clicked is the following:

<a href="#" onclick="callSomeJSFunction();">Click Me</a>

The problem I have often encountered is that clicking the link causes the browser to jump to the top of the page if you have scrolled at all. Users do not like unexpected behavior like this. I sometimes prefer to use a "clickable span" instead:

span.clickable_span{
cursor: pointer;
color: #[whatever your link color is];
}
<span class="clickable_span" onclick="callSomeJSFunction();">Click Me</span>

The span will have the same style as regular link (hand icon when the user mouses over) and the JavaScript function will be called.

Related posts:

  1. Real-time “AJAX” JavaScript Progress Bar
  2. Remove Firefox Link Outline
  3. JavaScript roundTo Nearest Thousandth, Hundredth, Tenth, *
  4. PHP jQuery AJAX Javascript Long Polling