小编Ste*_*ven的帖子

使函数等到元素存在

我正在尝试在另一个画布上添加画布 - 如何在创建第一个画布之前让这个函数等待启动?

function PaintObject(brush) {

    this.started = false;

    // get handle of the main canvas, as a DOM object, not as a jQuery Object. Context is unfortunately not yet
    // available in jquery canvas wrapper object.
    var mainCanvas = $("#" + brush).get(0);

    // Check if everything is ok
    if (!mainCanvas) {alert("canvas undefined, does not seem to be supported by your browser");}
    if (!mainCanvas.getContext) {alert('Error: canvas.getContext() undefined !');}

    // Get the context for drawing in the canvas
    var mainContext = …
Run Code Online (Sandbox Code Playgroud)

javascript jquery html5 function

123
推荐指数
10
解决办法
16万
查看次数

标签 统计

function ×1

html5 ×1

javascript ×1

jquery ×1