how to disable an html link?

satya - Wednesday, June 22, 2011 3:43:46 PM

you can do this


<a href="/someurl" onclick="javascript:somefunction">
this link wont fire
</a>

<script>
function somefunction()
{
  return false;
}
</script>

if you don't return false it will fire.

satya - Wednesday, June 22, 2011 3:44:55 PM

In jquery you can do this on an element like this


$(element).click(somefunction);

Notice that the prefix "on" is dropped for event based functions in jquery