App下載
首頁javascriptdrawing_settingsCanvas - 如何處理onclick事件

Canvas - 如何處理onclick事件

我們想知道如何處理onclick事件。




<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(function(){
    var getCanvasInfo = function (canvas) {
        var props = [],
            prop,
            ctx = canvas.getContext('2d');
        for (prop in ctx) {
            if ( prop !== "canvas" &&
                typeof ctx[prop] !== "function")
            {
                props.push(prop);
            }
        }
        return props.sort().map(function (p) {
            return p + ": " + ctx[p];
        }).join("\n");
    };
    console.log( getCanvasInfo( $("canvas")[0] ) );
});//]]>  
</script>
</head>
<body>
  <canvas></canvas>
</body>
</html>