Listen to this eventDOMSubtreeModified. means that if the child node of the currently monitored element is changed: including deleting a child node, adding a child node, or modifying the content of a child node, this event will be triggered.
var container = document.querySelector(".target") container.addEventListener('DOMSubtreeModified', function () { // do sth }, false);
You add a listening event in the dynamically adding element button, and then when the listening event is triggered, judge the length of the target element, and if there is a change, trigger an event
Listen to this event
DOMSubtreeModified
.means that if the child node of the currently monitored element is changed: including deleting a child node, adding a child node, or modifying the content of a child node, this event will be triggered.
You add a listening event in the dynamically adding element button, and then when the listening event is triggered, judge the length of the target element, and if there is a change, trigger an event
Can you determine the length of the target element to trigger it after you add the element dynamically?