Solution to the invalid id binding event in jquery appaend element

小云云
Release: 2017-12-29 09:36:21
Original
1464 people have browsed it

In the append element in jquery, if there is an id value in the element and the event is bound, the id event will be invalid and must be refreshed before it can be used. This article mainly brings you an article to solve the problem of invalid id binding event in jquery appaend element. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.

Solution:

Example: If in a

, add a button with id="demo" through append, commonly used The direct $("Selector").on("eventType",function(){}) listening event function does not work. For example, the click listening event of the button should be written like this:

$(".title").on("click", "#demo", function(){});
Copy after login

Related recommendations:

Detailed explanation of the problem of JQuery binding events in the loop

Detailed explanation of Cpage.js binding event instances to components

javascript uses event attributes to bind event functions in detail

The above is the detailed content of Solution to the invalid id binding event in jquery appaend element. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!