zoukankan      html  css  js  c++  java
  • 鼠标滑过显示图片

    当鼠标滑过某个制定位置,弹出div图片。移出,图片消失。

    1、js 

    $(function() {
    
    	    $("#div_Content").mouseover(function() {
    	        $(this).show();
    	    });
    
    	    $("#div_Content").mouseleave(function() {
    	        $(this).hide();
    	    });
    
    
    	    //初次加载
    	    Loading();
    
    	    //鼠标经过
    	    $(".a_float").mousemove(function() {
    
    	        var _showDiv = $(this).attr("rel");
    	        
    	        $("#" + _showDiv + " img").eq(0).attr("src","<%=path %><spring:message code="head.weChatFocus"/>" );
    
    	        //替换完成
    
    	        $(this).mouseover(function() {
    
    	            var _l = getLeft(this);
    	            var _t = getTop(this) + $(this).height();
    	            $("#" + _showDiv).css("top", _t); $("#" + _showDiv).css("left", _l);
    	            $("#" + _showDiv).show();
    	        });
    	        $(this).mouseleave(function() {
    
    	            $("#" + _showDiv).hide();
    	        });
    
    	    });
    
    	});
    
    	//鼠标经过
    
    	function getTop(e) {
    	    var offset = e.offsetTop;
    	    if (e.offsetParent != null) offset += getTop(e.offsetParent);
    	    return offset;
    	}
    	function getLeft(e) {
    	    var offset = e.offsetLeft;
    	    if (e.offsetParent != null) offset += getLeft(e.offsetParent);
    	    return offset;
    	}
    
    
    	function Loading() {
    
    	    $(".a_float").each(function() {
    	        var _showDiv = $(this).attr("rel");
    
    	        $("#" + _showDiv + " img").eq(0).attr("src", "<%=path %><spring:message code="head.weChatFocus"/>");
    
    	        //替换完成
    
    	        $(this).mouseover(function() {
    	            var _l = getLeft(this);
    	            var _t = getTop(this) + $(this).height();
    	            $("#" + _showDiv).css("top", _t); $("#" + _showDiv).css("left", _l);
    	            $("#" + _showDiv).show();
    	        });
    	        $(this).mouseleave(function() {
    	            $("#" + _showDiv).hide();
    	        });
    
    	    });
    	}

     2、页面引入

    <!--浮动产品模板开始-->
    	<div id="div_Content" class="jy_recom div_style"><a href="#" target="_blank"><img src="img/wechart.jpg" alt="" width="206" height="262" /></a>
    	</div>
    	<!--浮动产品模板结束-->
    人生苦短,我用python
  • 相关阅读:
    ArrayList集合 、特殊集合
    二维数组 、多维数组
    一维数组
    类:String,Math,DateTime,Random
    while做法1.兔子生兔子 2.求100以内质数的和3.洗发水15元 牙膏5元 香皂2元 150元的算法
    博客迁移
    [WC2008]游览计划 「斯坦那树模板」
    [SDOI2009]HH去散步 「矩阵乘法计数」
    [HNOI2007]梦幻岛宝珠 「套路:分层 $DP$」
    多项式求逆
  • 原文地址:https://www.cnblogs.com/pigga/p/10098304.html
Copyright © 2011-2022 走看看