jquery 实现鼠标悬浮在某控件上,显示详细信息

<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        #livetip
        {
            position: absolute;
            background-color: #cfc;
            padding: 4px;
            border: 2px solid #9c9;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
        }
    </style>
    <script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            var $liveTip = $('<div id="livetip"></div>').hide().appendTo('body');
            var tipTitle = '';

            $('#myDiv').bind('mouseover mouseout', function (event) {
                var $link = $(event.target).closest('input');
                if ($link.length < 1) { return; }
                var link = $link[0];
                if (event.type == 'mouseover') {
                    $liveTip.css({
                        top: event.pageY,
                        left: event.pageX
                    });

                    link.title = '';
                    $liveTip.html('<div>' + link.value + '</div>').show();
                };

                if (event.type == 'mouseout') {
                    $liveTip.hide();
                    if (tipTitle) {
                        link.title = tipTitle;
                    };
                };
            });
        });
    </script>
</head>
<body>
     <div id="myDiv">
        <input id="radio1" type="radio" value="Blue" name="radio1">Blue</input>
        <input id="radio2" type="radio" value="White" name="radio1">White</input>
        <input id="radio3" type="radio" value="Red" name="radio1">Red</input>
    </div>
</body>

相关推荐