I have this JavaScript function :
function putVote(trackid, vote) {
}
and I call this function trought :
<a href="#" onClick="putVote('data1', 'data2')">Link</a>
I would like to use e.preventDefault();
on putVote()
, but I think I'm wrong in some ways. How can I do it?
Cheers
The simplest thing to do would be to return false
from the function in the handler (return false
would only work in putVote
if the handler had return putVote('data1', 'data2)
).
But as Pointy said, a much better technique is to attach the event handler from JavaScript, most easily achieved by using a library/framework such as jQuery or Prototype.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With