Home > Article > Web Front-end > How to deal with the failure of id binding in jquery's appaend element
This time I will show you how to deal with the invalid id binding in jquery's appaend element. What are the precautions for dealing with the invalid id binding in jquery's appaend element? The following is a practical case. Let's take a look. one time.
In the append element in jquery, if the element has an id value and is bound to an event, the id event will be invalid and must be refreshed before it can be used.
2. Solution:
Example: If in a158bbedad335866a0f7aa9dcbb28e36794b3e26ee717c64999d7867364b1b4a3, add a button with id="demo" through append. The commonly used method is to listen to events directly with $("Selector").on("eventType", function(){}) The function does not work. For example, the click listening event of the button should be written like this:
$(".title").on("click", "#demo", function(){});
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
jquery reference React step-by-step explanation
jQuery makes mouse wheel operation image zoom size
jQuery creates page mask layer effect
The above is the detailed content of How to deal with the failure of id binding in jquery's appaend element. For more information, please follow other related articles on the PHP Chinese website!