What does "javascript.void()" mean?
If I'm triggering a JS function with a link, I would normally write it like this:
<a href="#" id="doSomething">hit me</a>
And then my code would be something comparable to this:
$('#doSomething').onclick(
function()
{
something powerful
});
I'm working on some code that has this:
<a href="javascript:void(0);"
class="open-company-detail
s" data-company-id="5e7c9a662
bfed251b42
81e51" data-route="companies">Loo
se Cannon Fitness</a>
When I go out to resources such as this:
https://www.tutorialspoint.com/What-does-javascript-void-0-mean, I get this definition:
If inserting an expression into a web page results in an unwanted effect, then use JavaScript void to remove it. Adding “javaScript:void(0)”, returns the undefined primitive value.
It SOUNDS like it's doing something like "#," but maybe a little more?
What does it mean and why would I want to use it as opposed to "#?" I'm thinking the bottom line is to tell the system to basically ignore the normal protocol. "I'm telling my link, Yes,you're normally a link, but, in this instance you're triggering some JS." That's what I'm doing with the "#" character, yes?
So, why javascript.void()?
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.