我封装的这个方法老是多次执行,大师们帮我指点一下怎么解决
function artistid()
{
var check = 0;
$('.artistid').mouseover(function(){
if(check!=1)
{
var aid = $(this).attr('lang');
var aid2 = $(this).attr('dir');
$('#intro').slideToggle(500);
document.getElementById("intro").innerHTML="<span style='font-size:20px'>loading</span>";
offset = $(this).offset();
xx = offset.left;
yy = offset.top;
document.getElementById("intro").style.left = xx +'px';
document.getElementById("intro").style.top = yy +'px';
$.post('ajax.php',{aid:aid,aid2:aid2},function(data){
document.getElementById("intro").innerHTML = data;
})
check=1;
}
});
$('.artistid').mouseout(function(){
if(check==1)
{
$('#intro').html('');
$('#intro').fadeOut('normal');
check=0;
}
});
}
function artistid()
{
var check = 0;
$('.artistid').mouseover(function(){
if(check!=1)
{
var aid = $(this).attr('lang');
var aid2 = $(this).attr('dir');
$('#intro').slideToggle(500);
document.getElementById("intro").innerHTML="<span style='font-size:20px'>loading</span>";
offset = $(this).offset();
xx = offset.left;
yy = offset.top;
document.getElementById("intro").style.left = xx +'px';
document.getElementById("intro").style.top = yy +'px';
$.post('ajax.php',{aid:aid,aid2:aid2},function(data){
document.getElementById("intro").innerHTML = data;
})
check=1;
}
});
$('.artistid').mouseout(function(){
if(check==1)
{
$('#intro').html('');
$('#intro').fadeOut('normal');
check=0;
}
});
}
var elem = $(event.currentTarget),
fromElem = $(event.relatedTarget);
if(elem.has(fromElem).length === 0 || !fromElem.is(elem)){
//todo...
}
});
<td class='artistid' lang='11' dir='tan'><a href='{$index_url}' class='play' name='artist' id='$ti'>xxxxxx</a></td>
yy = offset.top;
document.getElementById("intro").style.left = xx +'px';
document.getElementById("intro").style.top = yy +'px';
var timeObj;
$('.a').mouseover(function(){
clearTimeout(timeObj);
var $this = $(this);
timeObj = setTimeout(function(){
var offset = $this.offset(),
xx = offset.left,
yy = offset.top;
$('#intro').slideToggle(500).css({left: xx, top: yy}).html("要正确啊啊");
}, 600);
});
$('#intro').mouseout(function(){
$(this).fadeOut('normal').html("");
})
还是多次的