[英]How can I transform my this js code so that every property of an object get updated by an input value and radio button value?
我有一个object
与3个属性(amount,date,type)
。每次对象被自动调用最新的更新。 这是代码
var Transaction = function(amount, type) {
this.amount = amount;
this.type = type;
this.date = (function() {
var d = new Date();
var minutes = d.getMinutes();
var month = d.getMonth() +1;
if (minutes<10) {
return (d.getDate() + "/" + month + "/" + d.getFullYear() + " " + d.getHours() + ":" + "0" + minutes);
} else {
return (d.getDate() + "/" + month + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes);
}
})();
我如何设置它,以便amount
可以接收html输入字段的值并从单选按钮type
值? 我想使用纯JS
如果传递了输入字段,它将使用它的值,否则只需使用传递的值
this.amount = amount.value || amount;
this.type = type.value || type;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.