怎样重复运行上一次的函数,
点击了fn_1,再点击repeat_action就是运行fn_1();
点击了fn_2,再点击repeat_action就是运行fn_2();
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function fn_1(){
alert(1);
}
function fn_2(){
$("html").css("background-color","#eeeeee");
}
function fn_3(){
alert("hello");
}
function fn_4(){
$("html").css("background-color","transparent");
}
function repeat_acticon(){
//怎样重复上一次运行的动作?
//如:上一次运行fn_1(),则运行repeat_acticon()就是等于重复运行一次fn_1()
}
</script>
<button onclick="fn_1()">fn_1</button>
<button onclick="fn_2()">fn_2</button>
<button onclick="fn_3()">fn_3</button>
<button onclick="fn_4()">fn_4</button>
<button onclick="repeat_acticon()">repeat_acticon</button>
点击了fn_1,再点击repeat_action就是运行fn_1();
点击了fn_2,再点击repeat_action就是运行fn_2();
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function fn_1(){
alert(1);
}
function fn_2(){
$("html").css("background-color","#eeeeee");
}
function fn_3(){
alert("hello");
}
function fn_4(){
$("html").css("background-color","transparent");
}
function repeat_acticon(){
//怎样重复上一次运行的动作?
//如:上一次运行fn_1(),则运行repeat_acticon()就是等于重复运行一次fn_1()
}
</script>
<button onclick="fn_1()">fn_1</button>
<button onclick="fn_2()">fn_2</button>
<button onclick="fn_3()">fn_3</button>
<button onclick="fn_4()">fn_4</button>
<button onclick="repeat_acticon()">repeat_acticon</button>
var num=0
function fn_1(){
num=1;
alert(1);
}
function fn_2(){
num=2;
$("html").css("background-color","#eeeeee");
}
function fn_3(){
num=3;
alert("hello");
}
function fn_4(){
num=4;
$("html").css("background-color","transparent");
}
function repeat_acticon(){
if(num=1){fn_1()}//或者用Select Case
//怎样重复上一次运行的动作?
//如:上一次运行fn_1(),则运行repeat_acticon()就是等于重复运行一次fn_1()
}
</script>
js有没有办法返回fuction的名称?
如
function fn_name(){
return fn_name;
}