好吧,这应该是一个简单的问题,但现在已经让我头疼了两天。我有以下内容:
<a href="javascript:void();" onclick="return manage(id, value)">Add or remove</a>
管理功能如下
function manage(id, param){
var my_value;
alert(my_value); // this keeps giving me undefined. I want it to hold the last value of the param
if(param!=0){ // value not empty, we are removing
my_value = remValue(id, param);
}
else if(param==''){ // value is empty, so we are adding
my_value = addValue(id, param);
}
alert(my_value);
}
function addValue(id, param){
param += 1;
return param;
}
function remValue(id, param){
param -= 1;
return param;
}
整个想法是在添加或删除操作之后将 param 的值分配给 my_value 。请问有什么帮助吗?