Home javascript What is javascript: void (0) ;?

What is javascript: void (0) ;?

Author

Date

Category

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:
An example of how to see the js processing script


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


Answer 6, authority 6%


Answer 7

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions