MD Sayem Ahmed
MD Sayem Ahmed

Reputation: 29186

JQuery live function doesn't work

I have some text boxes, all of which have the same class "addExamNumberBoxStyle". Now I want to bind a "blur" handler to each one of these. When I use direct "blur" event like below -

$('.addExamNumberBoxStyle').blur(function()
{
    alert("Hello World");
});

it works perfectly. But when I use "live" function like below -

$('.addExamNumberBoxStyle').live('blur', function()
{
    alert("Hello World");
});

it does not work.

Why?

Upvotes: 0

Views: 270

Answers (1)

Quentin
Quentin

Reputation: 944555

Presumably because you don't have a new enough version of jQuery

  • In jQuery 1.3.x only the following JavaScript events (in addition to custom events) could be bound with .live(): click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup.

  • As of jQuery 1.4 the .live() method supports custom events as well as all JavaScript events. As of jQuery 1.4.1 even focus and blur work with live (mapping to the more appropriate, bubbling, events focusin and focusout).

http://api.jquery.com/live/

Upvotes: 1

Related Questions