`
少女杀手
  • 浏览: 130420 次
  • 性别: Icon_minigender_1
  • 来自: 约旦河西岸
社区版块
存档分类
最新评论

jquery实现照片显示信息效果

阅读更多
当鼠标移到图片上方时,在图片下面显示图片信息,当鼠标移出,图片信息消失

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript" src="jquery-1.3rc1.js"></script>
<script language="javascript" type="text/javascript">var $div = $( '<div></div>' ).css( { position: 'absolute', background: '#FC0', fontSize: '12px' } );
    $( document ).ready( function(){
        $( '#inimg' ).hover( function(){
            var imgTop = $( this ).offset().top;
            var imgHeight = $( this ).height();
            var imgWidth = $( this ).width();
            var instruct = $( this ).attr( 'instruct' );
            $div.text( instruct );
            var divHeight = $div.height();
            $div.css( { top:( imgTop + imgHeight - divHeight ), left: $( this ).offset().left, width: imgWidth } )
                .fadeIn( 'normal' ).appendTo( document.body );
        }, function(){
            $div.fadeOut( 'normal' );
        } );
    } );

</script>
</head>

<body>
<img src="xixi.jpg" id="inimg" instruct='图片说明' /><br/>
</body>
</html>
  • 大小: 35.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics