I have div
, and within it a canvas
without id
and other elements .
<div id="itens">
...
<canvas></canvas>
...
</div>
How can I get canvas
using JQuery
?
I have div
, and within it a canvas
without id
and other elements .
<div id="itens">
...
<canvas></canvas>
...
</div>
How can I get canvas
using JQuery
?
If you need the canvas inside the element #itens
1) $('#itens canvas')
selects all canvas
within element $itens
2a) To return only the first (or single) use $('#itens canvas').get(0)
or $('#itens canvas')[0]
2b) Or, as suggested by @JefersonAssis in the comments:
$ ('# canvas items: first-child')
If you want all canvas elements
1) $('canvas')
selects all the canvas on the page
2a) To return only the first (or single) use $('canvas').get(0)
or $('canvas')[0]
2b) Or, as suggested by @JefersonAssis in the comments:
$ ('# canvas items: first-child')