-----------------------For dynamic label binding events--------------------- ---
var outTimer;//Execution time
var upTimer;//Execution time
var sqDiv = $("#tm");//The div to be displayed
var test="";//Identification, in order to move the mouse to the displayed div
var dd = "";//Scratch the value passed by a certain field
function test1(){
$("#tm").empty();// Now clear the div
$.ajax({ //Add data in it
type: "post",
url: "<%=path %>/webmodule/constructionDecision/BaseCD/getCommunityInfo.do ?stCode=" dd,
dataType:"json",
async:false,
success:function(data){
var td="";
for(var i=0 ;i
td ="" data[i].name "";
}
$("#tm").append(td);
}
});
$("#tm").show();
}
function test2(){//How to hide div
if(test ==""){
$("#tm").hide();
}
}
$("#cityTable a").die().live('mouseover mouseout', function(event) { //Bind events to dynamic tags
if(event.type=='mouseover '){ //When moving up
clearTimeout(outTimer);//Clear the time out first, so as to avoid executing functions when the mouse is moved over and reduce the pressure on the server
dd=$(this).attr( "id");
upTimer = setTimeout(test1, 500);//Execute after 0.5 seconds
}
if(event.type=='mouseout'){
sqDiv.hover(
function(){
test = "on";//Indicates that the mouse is on the displayed div
}, function(){
test = "";
test2();
});
clearTimeout(upTimer);
outTimer = setTimeout(test2, 500);
}
});
------ -----------------------Non-dynamic tags (query information)--------------------- ----------------
//hoverDuring The delay time when the mouse passes
//outDuring The delay time when the mouse moves out
//hoverEvent The method executed when the mouse passes
//outEvent The method executed when the mouse moves out
$( function() {
$.fn.hoverDelay = function(options) {
var defaults = {
hoverDuring :200,
outDuring :200,
hoverEvent : function() {
$.noop();
},
outEvent : function() {
$.noop();
}
};
var sets = $.extend(defaults , options || {});
var hoverTimer, outTimer;
return $(this).each( function() {
$(this).hover( function() {
clearTimeout( outTimer);
hoverTimer = setTimeout(sets.hoverEvent, sets.hoverDuring);
}, function() {
clearTimeout(hoverTimer);
outTimer = setTimeout(sets.outEvent, sets.outDuring );
});
}); The code is as follows:
//$("#sosoFod h3").each( function() {
$("#sosoweb").each( function() {
hoverEvent: function() {
div.css("display", "block");
var p = that.position(); //Get the left and top of this element
var x = p.left that.width();//Get the left of this floating layer
var docWidth = $(document).width();//Get the width of the web page
if (x > docWidth - div.width() - 20) {
x = p.left - div.width();
}
div.css("left", x);
div.css ("top", p.top);
//$("#tm").show();
},
outEvent : function() {
$("#tm").hoverDelay( {
outDuring :1000,
hoverEvent : function() {
test = "on";
$("#tm").show() ;
},
outEvent : function() {
test="";
$("#tm").hide();
}
});
if(test==""){
$("#tm").hide();
}
}
});
});