用jquery循环获得所有input标签里的value值

时间:2024-01-07 09:07:02
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta id="viewport" name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
 <title>已打款列表</title>
 </head>
 <link type="text/css" href="../Publics/css/play_mine_list.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
 <body>

 <div class="container">
     <header class="clearfix">
       <!--<div class="one" style=" width:50px; height:50px;"><a href="reference_service.html"><img src="data:image/back.png"></a></div>-->
         <div class="two">打款列表</div>
     </header>
     <section>
     <volist name='order_list' id='val'>
         <div class="butt">
           <ul class="a">
                 <li class="aa"><font style="color:#f00;">工单号:</font></li>
                 <li><font style="color:#f00;">{$val.wnumber}</font></li>
             </ul>
             <ul class="a">
                 <li class="aa">打款金额:</li>
                 <input type='hidden' value='{$val.amount}' class='total_money' />
                 <li><font style="color:#f00;">{$val.amount}</font></li>
             </ul>
             <ul class="a">
                 <li class="aa">打款状态:</li>

                 <eq name="><li>已打款</li></eq>

                 <eq name="><li>打款中</li></eq>

                 <eq name="><li>等待打款</li></eq>

                 <eq name="><li>打款失败</li></eq>

             </ul>
             <ul class="a">
                 <li class="aa">打款时间:</li>
                 <li><font style="color:#f00;">{$val.time|date="Y-m-d H:i:s",###}</font></li>
             </ul>

         </div>
  </volist>
   <div class="butt">
   合计 :<font style='color:red;' ></font>元
   <button style='border-radius:25px;height:35px;width:80px;font-size:12px;color:#ffffff;background-color:#0AB0CB;' onclick='chakan_qian(this)' >查看合计</button>
   </div>
     </section>
     <footer>
         &copy;
     </footer>
 </div>
 </body>

 <script>
     function chakan_qian(elm){
         ; //这个一定要写在函数的外面
         $("input").each(function(){
             var total_money = $(this).val(); //这里的total_money就是每一个input的value值~
               total_moneys += parseInt(total_money);    //将获取到的值循环相加
         });
         //alert(total_moneys); //得到总的数值
         ){
             $(elm).prev().html(total_moneys);
         }
     }
 </script>
 </html>