在jQuery中设置一个计数器

编程入门 行业动态 更新时间:2024-10-09 21:27:11
本文介绍了在jQuery中设置一个计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个表单,其中包含基本的客户详细信息和信息.已经使用jquery来计算表单中字符的总数,现在我正在尝试实现计数器以查看填充表单所需的总时间,我的代码如下跟随

I have a form which includes basic client details and information.have used jquery to count total numbers of characters in the form and now I am trying to implement counter to see the total time taken to fill the form ,my codes are as follows

<html> <title> Employment Information </title> <style> table, td, th { border: 3px solid black; } td { padding: 15px; } </style> <script src="javascript/jquery-1.11.0.js"></script> // codes for getting total number of charatecs typed // <script> $('#form_3').on('submit', function(){ var count = 0; $('input[type="text"], textarea', this).each(function(){ count += $(this).val().length; }); alert("No of Characters Typed:" +count); return true; // or true to submit form }); </script> <body> <h4>MONTHLY INCOME AND COMBINED HOUSING EXPENSE INFORMATION</h4> <table border="1" width="1300" height="150"> <tr> <td>Gross monthly income</td> <td>Borrower</td> <td>Co-borrower</td> <td>Total</td> <td>Combined Monthly Housing Exp.</td> <td>Present</td> <td>Proposed</td> </tr> <tr> <td>Base EMPL income<</td> <td>$::<input type="text" name="empl_income" id="empl_income"></td> <td>$::<input type="text" name="co_borrower" ></td> <td>$::<input type="text" name="base_empl_total"></td> <td>Rent</td> <td>$::<input type="text" name=""></td> <td>$::<input type="text" name="years"></td> </tr> <tr> <td>Overtime</td> <td>$::<input type="text" name="overtime_borrower"></td> <td>$::<input type="text" name="overtime_coborrower"></td> <td>$::<input type="text" name="overtime_total"></td> <td>Mortgaged</td> <td>$::<input type="text" name="years"></td> <td>$::<input type="text" name="years"></td> </tr> </table> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="submit" name="submit" value="SUBMIT" onclick="return validateform();"> </form> </body> </html>

如何与字符计数代码一起实现计时器??

How can I implement a time counter along with the character count codes.?

推荐答案

var timeStart; var timeStop; $(document).load(function() { timeStart = new Date(); }); $('#form_3').on('submit', function() { timeStop = Math.round((timeStart.getTime() - Date().getTime()) / 1000); console.debug('time taken from load till submit: ' + timeStop); });

更多推荐

在jQuery中设置一个计数器

本文发布于:2023-10-18 15:32:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计数器   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!