How does the native js listen for events for later inserted elements

jq can use the on method to listen for later inserted elements. How to write

in native js
<div id="demo"></div>
<script>
    $("-sharpdemo").on("click", ".test", function () {
        console.log(66)
    })
    $("-sharpdemo").append("<p class="test">xxxx

") </script>
Mar.11,2021

document.getElementById('demo').addEventListener('click', function (e) {
       if(e.target.classList.contains('test')){
            console.log(66)
        }
    })

document.getElementById("demo").addEventListener("click", function(e){ 
      if(e.target.className==="test"){
        console.log(66)
      }
    });
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-1b3aac0-2c22b.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-1b3aac0-2c22b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?