Home  >  Article  >  Web Front-end  >  How to deal with the failure of id binding in jquery's appaend element

How to deal with the failure of id binding in jquery's appaend element

php中世界最好的语言
php中世界最好的语言Original
2018-04-19 15:34:391154browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn