jquery输入数字自动补全小数点效果
web jQuery 2017-09-14 2628 0
关于本站

“最难不过坚持”

本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作

有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339

6555848 2620 39
最新评论
https://jueru.net/
评 留言
:weixiao:
评 留言
:shuijiao: :weiqu: :zhenbang: :leng:
评 留言
:yiwen: :yiwen: :yiwen: :yiwen:
评 EasySass: could not generate CSS file. See Output panel for details.
这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
评 TP6模型事件-查询后onAfterRead不好用
文章标签更多
ThinkPHP (254)
Mysql (58)
DedeCms (33)
jQuery (67)
证件照 (1)
setInc (4)
setDec (4)
onclick (5)
打开边栏(ESC) 关闭边栏(ESC)

本文实现,jquery获得input框的值自动求和,并实现input框数字自动补充小数点后两个0,和也补充两个0.

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<script src="jquery.min.js"></script>
</head>

<body>
<script>

function moneyAllVal(){
	//输入框自动补全小数点
	$("input").on("blur",function(){
		$(this).val(parseFloat($(this).val()).toFixed(2));
	});
	//根据各项费用计算总金额
	moneyFoster = $('#moneyFoster').val() == '' ? 0 : $('#moneyFoster').val();
	moneyTrain = $('#moneyTrain').val() == '' ? 0 : $('#moneyTrain').val();	
	moneyAll = parseFloat(moneyFoster) + parseFloat(moneyTrain);
	//和自动补全小数点
	$('#moneyAll').val(parseFloat(moneyAll).toFixed(2));
}
   </script>
<form name="myform" method="post" id="myform" autocomplete="off">
	<table class="table table-hover table-striped table-bordered wst-form">
		<tr>
			<th width='170' align='right'>寄养:</th>
			<td><input type='text' id='moneyFoster' class="form-control wst-ipt" value='' maxLength='25' onchange="moneyAllVal()"/></td>
		</tr>
		<tr>
			<th align='right'>代训:</th>
			<td><input type='text' id='moneyTrain' class="form-control wst-ipt" value='' maxLength='25' onchange="moneyAllVal()"/></td>
		</tr>
		<tr>
			<th align='right'>合计金额:</th>
			<td><input type='text' id='moneyAll' class="form-control wst-ipt" value='' maxLength='25'/></td>
		</tr>
	</table>
</form>
</body>
</html>

版权声明:本篇文章来源于网络。 来源链接

相关推荐
TypeError: e.indexOf is not a function解决方法
jQuery | 2020-06-23 6394
This error might be caused by jquery event aliases like .load, .unload or .error deprecated since jQuery 1.8. Look for these aliases in your code and replace them with .o...
jQuery出现Uncaught TypeError: $(...).prop is not a function问题
jQuery | 2019-08-23 6370
做全选功能的时候用到 var xz = $(this).prop("checked"); 提示: Uncaught TypeError: $(...).prop is not a function 应该是jquery版本过低造成的,更换高版本成功解决问题, jquery下载地址 http://www...
评论:0条
评论加载中...
发表评论