What is the void in Javascript
Possible Duplicate:
what is the point of void in javascript
What does “javascript:void(0)” mean?
在任何地方,我都认为
那天我在页面中看到
我的问题很简单,为什么无效? 什么无效呢?
MDN文档页面
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).
在
我相信这是一种替代方法,即使在jQuery中也可以简单地终止点击。 将单击处理程序附加到锚标记时,应始终在处理程序的末尾返回false -
1 2 3 4 | $("#btn").on('click',function(){ // make toast return false; }); |
返回false将取消事件将执行的任何其他操作。
将