Skip to content Skip to sidebar Skip to footer

Uncaught SyntaxError: Unexpected Token ) When Using Void()

I get this error and I've managed to narrow it down to: aaa That line of code is now the only thing in my sour

Solution 1:

Use

<a href="javascript:void(0);" onclick="myFunction();">aaa</a>

void expects a parameter.

There's an interesting discussion on using void(0) or other techniques here.


Solution 2:

Is because void takes one argument. You want:

<a href="javascript:void(0);" onclick="myFunction();">aaa</a>

Solution 3:

void is an operator, not a function. It requires a single expression as its operand. () is not a valid expression. The correct syntax is:

<a href="javascript:void 0;" onclick="myFunction();">aaa</a>

You can put parentheses around 0, but they're not necessary, just as you don't need parentheses around 0 when writing 3 + 0.


Post a Comment for "Uncaught SyntaxError: Unexpected Token ) When Using Void()"