Today there is a get to a new point of knowledge, that is, when we add new elements to the page, the pre-load function method is invalid for the new element, let me say how to solve this problem?
I first look at the JQ API documentation did not find the method, no result had to find some information on the Internet, sure enough to find the live method.
It's actually very simple:
1. This is the project required to achieve the effect, when I do not use the live event, only with the simple hover event: The hover event is not loaded in, there is no border effect I want, as follows
/* Add style via user skill tag */
$ (function () {
$ (". s-edited"). Hover (function () {
$ (this). Toggleclass ("Borderd");
})
})
2. When I use live, the effect is achieved, such as:
The code is as follows:
/* Add style via user skill tag */
$ (". s-edited"). Live ("hover", function () {
$ (this). Toggleclass ("Borderd");
})
I took a closer look at the introduction of live,
A matching element binds an event handler function (such as the hover event). Custom events can also be bound.
PS: I am a novice rookie, big God do not spray!
How do I resolve an event's binding problem after jquery append new elements to the page?