我想要一个元素在doubleclick事件上切换,但它不起作用。
function doubleClick(e,fteven,position,oppname,mftname) {
var opponentstand = 'png.png';
var opponentrun = 'gif.gif';
var ftplayerstand = 'png.png';
var ftplayerrun = 'gif.gif';
var oppodd = fteven - 1;
jQuery('#div_label_ft').toggle(
function(){
var distance = jQuery('#div_label_opp').offset().left - jQuery('#div_label_ft').offset().left;
jQuery('#div_img_opp').removeAttr('src',opponentstand).attr('src',opponentrun);
jQuery('#div_img_ft').removeAttr('src',ftplayerstand).attr('src',ftplayerrun);
jQuery('#div_label_ft').animate({
'left': '+='+distance,
}, 1500,function(){
jQuery('input[type=radio]#div_ft').attr('checked',false);
jQuery('#div_img_ft').removeAttr('src',ftplayerrun).attr('src',ftplayerstand).css('transform','rotateY(180deg)');
});
jQuery('#div_label_opp').animate({
'right': '+='+distance,
}, 1500,function(){
jQuery('input[type=radio]#div_opp').attr('checked',true);
jQuery('#div_img_opp').removeAttr('src',opponentrun).attr('src',opponentstand).css('transform','rotateY(360deg)');
});
},
function(){
var distance = jQuery('#div_label_opp').offset().left - jQuery('#div_label_ft').offset().left;
jQuery('#div_img_opp').removeAttr('src',opponentstand).attr('src',opponentrun);
jQuery('#div_img_ft').removeAttr('src',ftplayerstand).attr('src',ftplayerrun);
jQuery('#div_label_ft').animate({
'left': '+='+distance,
}, 1500,function(){
jQuery('input[type=radio]#div_ft').attr('checked',false);
jQuery('#div_img_ft').removeAttr('src',ftplayerrun).attr('src',ftplayerstand).css('transform','rotateY(360deg)');
});
jQuery('#div_label_opp').animate({
'right': '+='+distance,
}, 1500,function(){
jQuery('input[type=radio]#div_opp').attr('checked',true);
jQuery('#div_img_opp').removeAttr('src',opponentrun).attr('src',opponentstand).css('transform','rotateY(180deg)');
});//
});
}
这是我正在使用的功能。
正在进行第二次双击完全正常。但不是第一次双击事件。
请指导!