当前位置: 代码迷 >> Web前端 >> jquery 直接获取全部表单的内容
  详细解决方案

jquery 直接获取全部表单的内容

热度:111   发布时间:2013-08-01 15:23:18.0
jquery 直接获取所有表单的内容

下面给出查看帮助文档的例子

?

<script src="jquery-1.4.4.js"></script>

<script>


$(function(){
	$("#results").append( "<tt>" + $("form").serialize() + "</tt>" );
});
</script>

<p id="results"><b>Results: </b> </p>
<form>
  <select name="single">
    <option>Single</option>
    <option>Single2</option>
  </select>
  <select name="multiple" multiple="multiple">
    <option selected="selected">Multiple</option>
    <option>Multiple2</option>
    <option selected="selected">Multiple3</option>
  </select><br/>
  <input type="checkbox" name="check" value="check1"/> check1
  <input type="checkbox" name="check" value="check2" checked="checked"/> check2
  <input type="radio" name="radio" value="radio1" checked="checked"/> radio1
  <input type="radio" name="radio" value="radio2"/> radio2
</form>

?

界面显示的内容是

?

直接使用ajax提交表单传递参数

$.ajax({
      type: "POST",
      url: url,
      data: $('#form1').serialize(),
      success: function(msg){
        alert( "Data Saved: " + msg );
     }
  });

?

  相关解决方案