当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery on() delegated events against document or more specific

问题描述:

This question already has an answer here:

  • Global vs. local event handler binding for jQuery widget [closed]

    2 answers

网友答案:

second one is better , faster performance wise.. your are delegating the event to the closest static parent which is always better than the document itself..as it doesnot have to traverse through all the elements and document as a whole

网友答案:

Performance.

Though you would use the first one in the event that the element you are attaching the event handler to was inserted into the DOM after page load.

分享给朋友:
您可能感兴趣的文章:
随机阅读: