开发者

jQuery Dependencies?

Say I have a jquery function that takes an element: <div id="hello"></div> and maninpulates the DOM and appends lots of new elements onto it, e.g.

<div id="hello"></div>

*run jquery fun开发者_JS百科ction*

<div id="hello"><div id="a"></div><div id="b"></div></div>

Ive encountered the problem that trying to select $('#a') or $('#b') on 'document.ready' returns 0 items as the first function obviously hasnt finished yet.

What are my options?

I've tried using $.live() to some success.


jQuery 'delegate' is the preferred method for binding events to dynamically created elements. See the documentation for reasons why.

http://api.jquery.com/delegate/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜