GetElementsByTagName gets the video tag, prints it out, but doesn't actually get it?

scenario: click the directory and insert the video tag on the page. Get video start playback event after insertion
problem: dom information can be printed, but the length of the object is 0 and the event cannot be bound. The real problem is that the append structure is successful in dom, but the browser has not yet been redrawn, and the binding event fails. Is there any other way to use setTimeout,?
clipboard.png

clipboard.png

Mar.15,2021

What's the difference between

getElementsByTagName and querySelector ?

The
Element.getElementsByTagName () method returns a dynamic HTML collection HTMLCollection that contains all the elements of the specified tag signature. The subtree of the specified element is searched, excluding the element itself. The returned list is dynamic, which means that it automatically updates itself as the DOM tree changes. Therefore, when using the same elements and parameters, it is not necessary to call Element.getElementsByTagName ().
multiple times.

draw the point. this means that it automatically updates itself as the DOM tree changes . If it is dynamic, then the combination of console is actually a snapshot and dynamic. So come to the conclusion that video has not been inserted at that time. You can use querySelector to verify

.

Portal-go to MDN to see getElementsByTagName and HTMLCollection


you save the tag when you insert the video tag

< hr >

https://jsfiddle.net/r7seguvj/
can bind events immediately after creating an element. Even if the element does not have append into document, check the internal logic of the code


Note: getElement sssssssssssssssssssssssssssss . ByTagName

If

has s, it must be a class array object with a .item (0) to become document.getElementsByTagName ('video'). Item (0); when it is referenced by (HTMLCollection),.


post the code. Have you not inserted vedio


Hello? I would like to ask you how to solve this problem in the end. I also have this problem now?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b380a6-2c0e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b380a6-2c0e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?