相关疑难解决方法(0)

将"return false"添加到click事件侦听器的效果是什么?

很多时候我在HTML页面中看到过像这样的链接:

<a href='#' onclick='someFunc(3.1415926); return false;'>Click here !</a>
Run Code Online (Sandbox Code Playgroud)

return false那里有什么影响?

而且,我通常不会在按钮中看到它.

这是指定的吗?在w3.org的某些规范中?

html javascript

348
推荐指数
10
解决办法
42万
查看次数

jQuery提交功能无法正常工作

我对jQuery提交功能有一些疑问.

这是工作环境

jQuery:1.7.2,chrome(18.0.1025.168 m).

有两个问题.

第一名:

我的代码是这样的

HTML

<form id="test" action="..." method="post">
     <input type="text" />
     <input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)

jQuery的

$('#test').submit(function(){
      return false;
})
Run Code Online (Sandbox Code Playgroud)

问题是它在firefox和opera中工作得很好但是chrome.

2ST:

html:如上所述.

jQuery的:

$('#test').submit(function(){
      if(...)
         alert(something..);
      return false;
})
Run Code Online (Sandbox Code Playgroud)

它不适用于firefox,opera和chrome.它总是触发form.submit为什么.

我很困惑.谁能想出来谢谢!

jquery submit

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

html ×1

javascript ×1

jquery ×1

submit ×1