开发者

Using delegate() for dynamically added container

Could you explain me how I can catch click event for dynamically added checkbox? I can do it, but can't understand one thing - why can't use delegate() for dynamically added container for checkbox. Code is like that:

<p sty开发者_运维技巧le="blue">
<input type="checkbox" name="first" />
</p>

Example here.

In this example I never catch the message ".blue CLICK" but only see "#ch CLICK".


In your example - When the delegate is initialised the p element with the blue class does not exist. The container you setup the delegate on needs to exist in the dom.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜