可以啊,比如一个收款小程序
/**
* var price; //商品单价
* var num; //商品数量
* var receive; //收款金额
*/
function cashier(price, num, receive){
var sum; //商品总额
var out; //应找金额
if((price*num)>500){
sum=price*num*0.8
}
if(receiveout="金额不足";
}else{
out=receive-sum;
}
return "商品总额:"+sum+" 收款金额:"+receive+" 应找金额:"+out;
}
你的DOM元素中有符合元素吗?有