使用jquery修改表單的提交地址基本思路
更新時間:2014年06月04日 15:49:26 作者:
使用jquery選擇器得到對應表單的jquery對象,然后使用attr方法修改對應的action,需要的朋友可以參考下
基本思路:
通過使用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>
通過使用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>
相關(guān)文章
jQuery實現(xiàn)購物車多物品數(shù)量的加減+總價計算
這篇文章主要介紹了jQuery實現(xiàn)購物車多物品數(shù)量的加減+總價計算,需要的朋友可以參考下2014-06-06使用異步controller與jQuery實現(xiàn)卷簾式分頁
這篇文章主要介紹了使用異步controller與jQuery實現(xiàn)卷簾式分頁,使用異步controller與jQuery按需加載內(nèi)容,當用戶開始通過網(wǎng)站的內(nèi)容滾動時進一步加載內(nèi)容。,需要的朋友可以參考下2019-06-06JQuery模擬實現(xiàn)網(wǎng)頁中自定義鼠標右鍵菜單功能
這篇文章主要給大家介紹了關(guān)于利用JQuery模擬實現(xiàn)網(wǎng)頁中自定義鼠標右鍵菜單功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2018-11-11jquery.blockUI.js上傳滾動等待效果實現(xiàn)思路及代碼
上傳滾動等待效果想必大家在很多場合都有見過吧,本文將介紹jquery.blockUI.js實現(xiàn)上傳滾動等待效果,感興趣的你可不要錯過了哈,希望可以幫助到你2013-03-03GridView中獲取被點擊行中的DropDownList和TextBox中的值
本文為大家介紹下如何通過點擊GridView中的a標簽獲取被點擊行中的下拉框和文本框中的值,具體實現(xiàn)嗲嗎如下,感興趣的朋友可以參考下哈,希望對大家有所幫助2013-07-07