SVG rect上的鼠标事件

时间:2014-09-03 08:36:14

标签: javascript html svg javascript-events mouseevent

我试图在一个SVG矩形内的JavaScript中显示工具提示,以便在rect区域中显示MouseDown和mousemove事件。 问题是:我无法在每次鼠标移动和鼠标按下操作时捕获事件。 以下是我的示例代码:

<!DOCTYPE html>
<html>
    <body>
        <script src=jquery-2.0.2.js></script>
        <script>
            onMouseDown = function ( evt ) {
                evt.preventDefault();
                var tooltip = document.getElementById( 'tooltip' );
                tooltip.setAttribute( 'visibility', 'visible' );
                tooltip.setAttribute( 'x', evt.x );
                tooltip.setAttribute( 'y', evt.y );
            };

            onMouseMove = function ( evt ) {
                evt.preventDefault();
                var tooltip = document.getElementById( 'tooltip' );
                tooltip.setAttribute( 'visibility', 'visible' );
                tooltip.setAttribute( 'x', evt.x );
                tooltip.setAttribute( 'y', evt.y );
            };
        </script>

         

  

0 个答案:

没有答案
相关问题