zoukankan      html  css  js  c++  java
  • jquery submit()不能提交表单的解决方法

     

    1. <formid="form"method="get">
    2. <inputtype="text"name="q"value="XXX"/><buttontype="button"id="submit">查询</button>
    3. </form>
    4. <scripttype="text/javascript">
    5. $(function(){
    6. $('#submit').click(function(){
    7. $('#form').submit()
    8. })
    9. })
    10. </script>

    上述代码看上去貌似没什么问题,简直是普通了不能再普通的代码。可是点击查询按钮的时候死活不提交表单,按钮type改为submit表单提交正常。于是上JQUERY API查找原因,看到以下这段文字顿时明白了:

    Additional Notes: Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.

    其他注意事项: 表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, or method,是、会产生冲突。名称冲突可能会导致混乱的失败。对于一个完整的规则列表,并检查这些问题标记,看DOMLint。

  • 相关阅读:
    java 中for each语句
    设备树使用手册
    Java中 final static super this instanceof 关键字用法
    Java 抽象类与oop三大特征
    Views的补充
    Form表单组件验证
    django信号相关
    缓存实例
    自定义django中间件
    【主机管理项目】-(路由表)
  • 原文地址:https://www.cnblogs.com/EDSON/p/2848796.html
Copyright © 2011-2022 走看看