Self written jQuery asynchronous load data add events

  • 2020-03-30 03:00:14
  • OfStack

A few months ago, I was involved in a project with a tree bar, and then I looked at a lot of plugins, and I felt a little bit troublesome.

At that time, the project was controlled by the tree bar, and the administrator could dynamically generate the tree bar from the database to add, delete and change the check operation, but with $(".xx ").click(); The way is not right.

1. Jq1.4.3 was used before, and jq1.7 can use the live() method to achieve this function
$( ' #div').live( ' click',function(){ 

//do stuff 


However, the live method also has unsupported events, such as the toggle event. In this case, you can add a click event to it, and then simulate the click trigger event


2, jq1.7 above the use of the on method, the first property is the event, the second is the selector, the third is the method of execution

Related articles: