栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

获得所有表单值的JQuery实现代码[IE暂不支持]

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

获得所有表单值的JQuery实现代码[IE暂不支持]

IE 暂不支持
CSS:
复制代码 代码如下:

        body{
             margin:0;
             padding:0;
        }
        div{
            margin:0;
            padding:0;
        }
        .container{
            margin-left:10%;
            margin-right:10%;
        }
        ul li{
            list-style:none;
        }
        ul{
            padding:0;
            margin:0;
        }
        p.em{
            color: red;
            border:1px solid red;
            padding:0 10px;
            margin:0;
        }
        p.small {line-height:90%}
        p {line-height:110%}
        #left{
            float:left;
            width:300px;
            padding:0;
            margin:0 10px 0 0 ;
            border-right:1px solid #AECEEB;
        }
        #right{
            margin-left:300px;
        }
        span.clear{
            clear:both;
        }
        h2{
            border-bottom:1px solid #AECEEB;
        }
   

JS:
复制代码 代码如下:
function form(){
        $('#myform').submit(function() {
            // get text value
            var tv = $("#mytxt").val(),
                    tf = $(this).find(":input[type='text']").val(),
                    tn = $(this).find(":input[name='txtname']").val();
            $("#result1").text(tv);
           
            //$("#result1").delay(30000).fadeOut();
            //tv.attr(value, ''); clean value
            // get textarea value
            var av = $("#myarea").val();
            $("#result2").text(av);
           
            //$("#result2").delay(30000).fadeOut();
            var str = "";
       
        // $("select[name='garden'] option:selected")  if we have multiple select
        $("select[id='mysel'] option:selected").each(function () {
          str = $(this).val();
        });
        $("#result3").text(str);
        var str2 = "";
        $("select[id='multisel'] option:selected").each(function () {
          str2 += $(this).val() + " ";
        });
        $("#result4").text(str2);
        var str3 = [];
        $("input[name='checkme']:checked").each(function(){
                 str3.push($(this).val());
        });
        var oa = "";
        $.each(str3, function(key,val){
            oa +=  key + ":" + val;
        });
        $("#result5").text(oa);
        var ck = $("input[type='radio']:checked").val();
        $("#result6").html( ck + " is checked!" );
            return false;
        });
    }
    form();

HTML:
复制代码 代码如下:


   



Get All Form Elments Value
















转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/112997.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号