Say I have a link:
<a href="http://www.example.com">Example!</a>
I want to keep the link intact, but I’d like an onclick event to decide if the link is clickable or not
<a onclick='stopLight()' href="http://www.example.com">Example!</a>
function stopLight() {
// conditional logic
// return true or return false
}
so if stopLight() == true, then link works, if stopLight() == false, then link doesn’t.
Is making this possible without changing the href, because I’d rather not
Use
return stopLight()for theonclickhandler.As mplungjan suggested in his comment