jQuery click function vs inline onclick

前端 未结 5 1836
广开言路
广开言路 2021-02-08 11:28

I\'m trying to reorganize my code and make it more unobstrusive.

Mainly, there is a link for performing an action. If you click on the link, the action is performed via

5条回答
  •  梦谈多话
    2021-02-08 12:30

    Since you are dynamically adding new items to the DOM, you will have to register the click handler again on the new items.

    You can use .live for this.


    Update

    Since jQuery 1.7, the .on method is preferred way to do this.

    Since jQuery 1.9 the .live method has been removed.

提交回复
热议问题