当前位置:编程学习 > JAVA >>

JQuery获得所有表单值

IE 暂不支持
CSS:
  View Code
 
<style>
        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;
        }
    </style>
 
JS:
  View Code
 
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").append("You can get the value of text use these methods below: <br />"
                            + "<b>" + tv + "</b>" + "<br />"
                            + "<p class='em'>" + '$("#mytxt").val()' + "<br />"
                            + '$(this).find(":input[type=\'text\']").val()' + "<br />"
                            + '$(this).find(":input[name=\'txtname\']").val()'  + "<br />"
                            + "</p>");
            */
           
            //$("#result1").delay(30000).fadeOut();
            //tv.attr(value, ''); clean value
            // get textarea value
           
            var av = $("#myarea").val();
            $("#result2").text易做图;
            /*    $("#result2").append("You can get the value of textarea use these methods below: <br />"
                            + "<b>" + av + "</b>" + "<br />"
                            + '<p class=\'em\' >$("#myarea").val()'
                            + "</p>");
            */
            //$("#result2").delay(30000).fadeOut();
           
            var str = "";
        /*    $("select").change(function () {
         
          $("select option:selected").each(function () {
                str += $(this).val();
 &nbs

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,