欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用jquery修改表單的提交地址基本思路

 更新時(shí)間:2014年06月04日 15:49:26   作者:  
使用jquery選擇器得到對(duì)應(yīng)表單的jquery對(duì)象,然后使用attr方法修改對(duì)應(yīng)的action,需要的朋友可以參考下
基本思路:

通過使用jquery選擇器得到對(duì)應(yīng)表單的jquery對(duì)象,然后使用attr方法修改對(duì)應(yīng)的action

示例程序一:

默認(rèn)情況下,該表單會(huì)提交到page_one.html

點(diǎn)擊button之后,表單的提交地址就會(huì)修改為page_two.html
復(fù)制代碼 代碼如下:

<!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
復(fù)制代碼 代碼如下:

<!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)文章

最新評(píng)論