I have a <a> element that’s supposed to run code and not redirect.
here are two examples of code which I believe should have the same effect, but it wont:
this works:
<a href="#" onclick="alert('Works'); return false;" />
this won’t:
<a href="#" onclick="return function() {alert('don't Work'); return false;};" />
Shouldn’t they both do the same?
Isn’t the expression in the second attempt evaluated, calling the anonymous function and returning false?
Thanks!
The second example defines a function and returns it. It never calls it.
If you call it (and fix the quoting error), then you would get the same effect.