javascript - Add eventlistener to canvas tag -
I get the An optional canvas tag correctly from HTML, but when I make it an event Try, console returns me
unchecked typed error: there is no undefined function . I do not understand the reason.
var x = document.getElementsByTagName ('canvas'); Console.log (x); // Print correctly elements: [canvas, item: function, named: function] x.addEventListener ("click", provision); // UnkitType Error: Undefined No Function Function (Event) {console.log ("Prova"); //};
document.getElementsByTagName ("canvas") [0]
getElementsByTagName returns an HTMLCollection (like an array), and works on the
addEventListener elements, so that you You need to select the correct index.
document.query selector ("canvas") is which will return an element.
html वेब डिज़ाइन नमूना कोड स्निपेट
ReplyDeleteनमूना कोड के चारों ओर पाठ आवरण के साथ दाईं ओर फ्लोट