jquery控制层不超出屏幕范围
$(document).ready(function(){ var _lll= $(window).width(); var _mmm = 0; $(".valuation li img").mouseover(function(e){ titles=$(this).attr("title"); $(this).attr("title",""); $(".valuation li").append("<div class='valtip'>"+titles+"</div>"); var _kkk= $(this).position().left; var _jjj= $(".valtip").width()+84; if(e.pageX+10+_jjj>=_lll){ _mmm=_lll-_jjj-10; } else{ _mmm =e.pageX+10; } $(".valtip").css({"top":(e.pageY+10)+"px","left":(_mmm)+"px"}); }).mousemove(function(e){ var _kkk= $(this).position().left; var _jjj= $(".valtip").width()+84; if(e.pageX+20+_jjj>=_lll){ _mmm=_lll-_jjj-10; } else{ _mmm =e.pageX+10; } $(".valtip").css({"top":(e.pageY+10)+"px","left":(_mmm)+"px"}); }).mouseout(function(){ $(".valtip").remove(); $(this).attr("title",titles); }) $(window).bind("resize",function(){ _lll=$(window).width(); }); })