In the project, the background is php, and the request interface is convenient to generate nodes and add them to the page with jquery. The method is ancient. . . helpless.
But the project needs, no way. There is a problem in this process, which is that new elements cannot be added to events, which is embarrassing. . .
And it's still the kind of two-way data binding effect of angular. It's a headache for a long time, and the ink is still coming out. God, don't spray it. . .
Okay. . code above
$(document).on('input propertychange','#luckValue',function(){
var result = $(this).val();
if(result==""){
result = 0;
}
reg=/^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
// reg=/^([+-]?)((\d{1,3}(,\d{3})*)|(\d+))(\.\d{2})?$/g;
if(!reg.test(result)){
$(this).css("border","1px solid #b3403e");
$(".zongjia .text").text("请输入数字").css("color","red");
}else{
$(this).css("border","1px solid #d5d5d5");
var num = $(".save").attr("price");
$(".zongjia .text").text("¥"+(parseFloat(result)+parseFloat(num))).css("color","#000");;
$(".zongjia .colors").text("(including shipping fee:¥"+result+"yuan)")
}
})
======================= ==========================================
$(document).on('input propertychange','#luckValue',function(){})
input propertychange: event response listener, if a change event occurs, it will be triggered immediately
#luckValue: The element to be monitored The
third parameter: triggering the function that needs to be executed
can achieve finding nodes, triggering events, and one step. .
As for the following is the verification input field, which belongs to personal notes. .