zoukankan      html  css  js  c++  java
  • 使用jquery改动表单的提交地址

    基本思路:

    通过使用jquery选择器得到相应表单的jquery对象,然后使用attr方法改动相应的action

    演示样例程序一:

    默认情况下,该表单会提交到page_one.html

    点击button之后,表单的提交地址就会改动为page_two.html

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>jquery test</title>
    <script src="jquery-1.11.1.min.js"></script>
    </head>
    
    <body>
    <div>
    <form action="page_one.html" id="qianshou">
    <input type="text"/>
    <input type="submit" value="提 交"/>
    </form>
    </div>
    <div>
    <button name="update">改动form的提交地址为page_two.html</button>
    </div>
    </body>
    <script>
    var $fun = $('button[name=update]');
    $fun.click(function(){
    	$('form[id=qianshou]').attr('action','page_two.html');
    });
    </script>
    </html>
    

    演示样例程序二:

    form本来的action地址是page_one.html,通过jquery直接改动为page_two.html

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>jquery test</title>
    <script src="jquery-1.11.1.min.js"></script>
    </head>
    
    <body>
    <div>
    <form action="page_one.html" id="qianshou">
    <input type="text"/>
    <input type="submit" value="提 交"/>
    </form>
    </div>
    </body>
    <script>
    $('form[id=qianshou]').attr('action','page_two.html');
    </script>
    </html>
    


  • 相关阅读:
    iOS 数字滚动 类似于老
    iOS 实现转盘的效果
    iOS 摇一摇的功能
    APP上架证书无效:解决
    iOS--UIAlertView与UIAlertController和UIAlertAction之间的事儿
    ios 获取字符串所需要占用的label的高度
    适配----Autolayout
    OC中 block 的用法
    微信小程序如何播放腾讯视频?
    IOS-UICollectionView
  • 原文地址:https://www.cnblogs.com/wzjhoutai/p/6805307.html
Copyright © 2011-2022 走看看