jayroe
jayroe
2017-02-10 09:21

请教:为什么我创建的canvas元素,都消失了?

  • canvas
  • js
<body>
    <form>
        <select>
            <option value="2">简单</option>
            <option value="3">困难</option>
        </select>
        <button id="starBtn">开始</button>
    </form>

    <section>

        <canvas class="canvasSection" width="600" height="600" id="canvas1"></canvas>


        <!--相册-->
        <section id="album" class="canvasSection">

        </section>
        <section class="clear"></section>
        <img src="imgs/example.jpg" hidden="hidden" />
    </section>

</body>
<script>
var album ;//小canvas容器
var imageObj ;// 要绘画的图片
var canvas;//小canvas对象 

window.onload= function(){
var btn = document.getElementById("starBtn");//btn为我的一个按钮

btn.onclick = function(){
            for(var i =0;i<n;i++)
                for(var j=0;j<n;j++)
                {

                        canvas = document.createElement("canvas");
                        canvas.width = 300;
                        canvas.height=  300;
                        album.appendChild(canvas);

            }
        };


};
</script>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答