jQuery中设置form表单中action值与js有什么不同。。。。

 

jQuery中设置form表单中action值与js有什么不同。。。。

 

HTML代码如下:

<form action="" method="post" id="form_id" name="form_name">

  username:<input type="text" name="username" >

  username:<input type="text" name="username" >

  <input type="button" id="btn" value="测试">

</form>

 

在js里面有几种设置的方式:

  1.document.form_name.action = "***.action/html/jsp/...";

  2.document.form_name.attributes["action"].value  = "***.action/html/jsp/...";

  3.document.all("form_id").setAttribute("action", "欲赋的action的值");

  4.document.getElementById("from_id").action = "***.action/html/jsp/...";

  5.document.getElementsByName("from_id")[0].action = "***.action/html/jsp/...";//这是Elements,返回数组,此时取第一个form表单

 

在jquery里面设置form里面的action属性值:

  1.$("#from_id").attr("action", "***.action/html/jsp/...");

  

 注意!!!!

         $("#from_id").action="***.action/html/jsp/...";  这种写法是不起作用的!

 

posted @ 2015-08-24 09:16  liqz_work  阅读(1236)  评论(0编辑  收藏  举报