Capturing a tag through the jq selector triggers the ajax event request to be added to a new page and added to the specified div. What if the a tag in the div cannot be captured by the selector?

problem: there are many a tags in a page. After capturing through the jq selector, the ajax request is triggered and the HTML code is inserted into the specified container (< div id= "specify container" > < / div >). The a tag in the container cannot be captured by the jq selector.
requirements:

  1. on the page, click the a tag outside the container to request (backend) to put the HTML into the specified container [implemented]
  2. Click the a tag in the container to refresh the old HTML code in the container, and put the newly requested HTML code into it [current problem]

add: the company does not allow iframe

Apr.11,2021

use jQuery on

$(- sharp container ID) .on ("click", "a", function (e) {
/ / code
})


is the event delegate, and another answer has been given to a simple example. Let me explain in detail, suppose your page structure is:

<body>
  <div>
    <a href="" class="red"></a>
    <a href="" class="green"></a>
  </div>
  <a href="" class="red"></a>
</body>

where the a tag is what you call the specified event source, then you can delegate to listen for the events of the an element on the body.
Jquery is

$("body").on("click","a",function(e){ //"a"
    //someThing
})

your code involves dynamic addition and subtraction of HTML elements, and uniformly bind events, and the
event delegate is used in this case.

as for binding, we can see that all the elements that need to be delegated can be

one level above, or the outermost body or ducument.
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-1b3a8c2-2ba6c.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-1b3a8c2-2ba6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?