1

I want to execute something after rendering the DOM tree.

I'm trying to build an app by using canvas. In this process,

I try to do below.

getElementsByTagName('canvas');

But there is nothing.

If I surround my code with this.

setTimeout(...,0)

It will work.

I think it is caused by rendering. How to execute after render?

Kaiido
  • 103,356
  • 8
  • 183
  • 231
原裕貴
  • 25
  • 2

1 Answers1

0
document.body.onload = function() {
  var canvas = getElementsByTagName('canvas')[0]
  // do something with canvas
}
Rob Kwasowski
  • 2,580
  • 3
  • 10
  • 31