开发者

using jQuery .live with .bind

okay, I understand the basics of jQuery, and I know that in some instances I've had to use .live('click',function开发者_运维问答(){...}); instead of .click(function(){...}); to get the method to fire correctly.

the method I'm currently looking at is: $('#title').bind('keyup', function(){...});

This works great, except because it's in a bit of code that isn't called until another action is preformed, I'd need to use .live() as described above.

Problem is, I don't know how to format this one to work using the .live() method instead of .bind() as shown above. Can someone please help?

Thanks in advance!


Using live is the same as using bind, except that it is limited only to the events click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup.

$('selector').live('event',fn);


odd, I thought I saw the answer up, but then it seemed to disappear before I could accept. At any rate, using the following worked:

$('#title').live('keyup', function(){...});


@dskvr is correct - the usage syntax is the same. But you also might like to read up on the differences between live(), bind() and delegate().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜