现有这样的jquery click事件:
$(document).ready(function() {
$curtainopen = false;
$(".rightcurtain").click(function(){
$(this).blur();
if ($curtainopen == false){
$(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".rightcurtain").stop().animate({width:'60px'}, 5000 ); //这里的“60px”现在是固定值
$curtainopen = true;
}else{
$(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".rightcurtain").stop().animate({width:'82%'}, 5000 );//这里的“82%”现在是固定值
$curtainopen = false;
}
return false;
});
});
现在有不同的rightcurtain层,都需要调用这个click事件,但上面的60px和82%不是固定的。而是根据不同的层传递不同的参数,请问要怎么写?
$(document).ready(function() {
$curtainopen = false;
$(".rightcurtain").click(function(){
$(this).blur();
if ($curtainopen == false){
$(this).stop().animate({top: '0px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".rightcurtain").stop().animate({width:'60px'}, 5000 ); //这里的“60px”现在是固定值
$curtainopen = true;
}else{
$(this).stop().animate({top: '-40px' }, {queue:false, duration:350, easing:'easeOutBounce'});
$(".rightcurtain").stop().animate({width:'82%'}, 5000 );//这里的“82%”现在是固定值
$curtainopen = false;
}
return false;
});
});
现在有不同的rightcurtain层,都需要调用这个click事件,但上面的60px和82%不是固定的。而是根据不同的层传递不同的参数,请问要怎么写?
你的意思是说针对每一个层都要写一个click事件函数?
当点击click事件时,将该隐藏域的值设为你想传的值
然后$(".rightcurtain").stop().animate({width:'60px'}, 5000 );这里统一取隐藏域的值
click的时候,再去取自已的属性就行了