Guys, hello everyone.
Answer 1, authority 100%
void (0)
is an expression obtained by casting the constant 0 to void
. That is, a simple, meaningless expression.
Answer 2, authority 41%
When the browser clicks on a javascript:
link, it replaces the page content with the return value, unless undefined
is returned. The void
operator always returns this very value undefined
.
Answer 3, authority 24%
Answer 4, authority 21%
The construction of the type href = "javascript: void (0);"
is usually used when a js script should be triggered together with the usual following a link.
Examples of such cases are opening a modal window, sending / receiving data using ajax, or the need to validate some data using js before clicking on this link.
To find the script that is triggered when you click on this link, you should look in the inspector mode. An example of how this can be done, in the screenshot:
Answer 5, authority 12%
href = "javascript: void (0);"
are added so that when clicking on a link that does not perform its direct function, the page does not scroll up, but everything remains in place