zoukankan      html  css  js  c++  java
  • form表单转换为Json数据

    最近对前端js学习有点多,如今想自己动手写点插件,后来发现,我想到的,其他人都想到了。于是做了以下笔记。

    使用插件:

    插件 :https://github.com/marioizquierdo/jquery.serializeJSON  

    调用方式:

     console.log($('form[name="formEdit"]').serializeJSON());
    

    HTML代码:

     1 <div class="box">
     2         <div class="content">
     3            <form name="formEdit" method="post">
     4                <input name="id" value="1" type="text" /><br /> 
     5                <input name="name" value="jeamy" type="text" /><br />
     6                <input name="age" value="28" type="number" /> <br />
     7                <input name="sex2"   type="checkbox" checked="checked" /><br />
     8                <input name="sex1"   type="checkbox" checked="checked" /><br/>
     9                <textarea name="intro" cols="5" >dasdfasd</textarea> <br/>
    10                <select name="city">
    11                    <option value ="1">武汉</option> 
    12                    <option value ="2">北京</option> 
    13                    <option value ="3">纽约</option> 
    14                </select><br/>
    15              <label><input name="Fruit" type="radio" value="1"  checked/>苹果 </label> 
    16 <label><input name="Fruit" type="radio" value="2" />桃子 </label> 
    17 <label><input name="Fruit" type="radio" value="3" />香蕉 </label> 
    18 <label><input name="Fruit" type="radio" value="4" /></label> 
    19 <label><input name="Fruit" type="radio" value="5" />其它 </label> 
    20                <div>
    21                    <input type="button" onclick="getinfo();" value="提交" /> 
    22                </div>
    23            </form>
    24         </div>
    25     </div>
  • 相关阅读:
    Orchard1.4发布
    13个MVC的扩展
    不完全接触Node.js
    mac软件
    在Apworks框架中解除NHibernateContext与NHibernateRepository的依赖关系
    mac下我常用的一些软件
    在.NET应用程序中访问Excel的几种方式
    Visual Studio 11 Beta 官方下载地址
    欢迎使用 Windows 8 – Consumer Preview
    PHP学习系列之 环境配置
  • 原文地址:https://www.cnblogs.com/LearningC/p/8118504.html
Copyright © 2011-2022 走看看