Why not use jquery to get dynamically generated elements through events?

$("body"). On ("click", "selector", function () {})
this is the method that is called after the dynamically generated element is clicked.
I now dynamically generate input and then immediately get this dynamically generated element without triggering
through a click event. How can I get it?

Apr.26,2021

first heard that getting elements depends on events.
jquery is good at element filtering, isn't it?
you add a little filter flag to the newly generated input to filter directly, or you can directly createElement and get


right away.

when defining a variable globally, such as var countCreate = 0 , you can add some class or id, to dynamically generated elements, such as

.
var countCreate = 0
var set = document.createElement("li");
set.setAttribute('id', 'x:' + countCreate.toString());

so that each new element can be found independently through id.
even, this set is a new element, and you can do whatever you want.


event delegation

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-1eab7fd-205c.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-1eab7fd-205c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?