javascript void functions
Possible Duplicate:
What does"javascript:void(0)" mean?
我想问一些关于
1 | <input type='submit' name='btn' value='submit' onClick='javascript:void(0)' /> |
你能解释一下
无效():
This operator allows inserting expressions that produce side effects
into places where an expression that evaluates to undefined is
desired.The void operator is often used merely to obtain the undefined
primitive value, usually using"void(0)" (which is equivalent to"void
0"). In these cases, the global variable undefined can be used instead
(assuming it has not been assigned to a non-default value).
Note, however, that the javascript: pseudo protocol is discouraged over other alternatives, such as unobtrusive event handlers.
你可以在这个类似的主题上阅读更多内容:"javascript:void(0)"是什么意思?
1 | <input type='submit' value='submit' onClick='return false;' /> |
void是一个用于返回未定义值的运算符,因此浏览器将无法加载新页面。 关于void运算符的一个重要注意事项是它需要一个值,并且不能单独使用。
它定义了一个没有主体的事件处理函数,因此不执行任何操作。 您最常见的是在