提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
提示:此篇文章旨在记录自己在使用jquery是好用的方法
一、如何导入jquery?
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
二、多模块数据不能超过100
1.引入库
代码如下(示例):
var widget2 = $("<td><input type='text' class='form-control amount_of' name='amount_of[]' value='" + amount_of + "' readonly></td>");
widget2.on('input propertychange', '.amount_of', function () {
var value = $(this).val();
if (!$.isNumeric(value)) {
$(this).val('');
}
if (value > 100) {
$(this).val('');
}
var allValue = 0;
$.each($('.table-group').find(".amount_of"), function (i) {
var value = $('.table-group').find(".amount_of").eq(i).val();
allValue = parseFloat(allValue) + parseFloat(value);
console.log(allValue);
});
if (allValue > 100) {
$(this).val('');
allValue = 0;
}
var amount_pay = dataOther * value / 100;
widget3.children(".amount_pay").val(amount_pay);
});
2.选择项绑定显示/删除
代码如下(示例):
var ID = '#0Div';
$('#contract').change(function() {
console.log(ID)
$(ID).hide()
var data = $(this).val();
var ID1 = `#${data}Div`
var ID2 = ID1.split(" ")
var ID3 = ID2[0] + ID2[1]
ID = ID3
console.log(ID3)
$(ID3).show()
// console.log($('#6Div').children('#nameInput'))
})
总结
提示:旨在记录工作中用到的一些好方法,方便使用和学习