1

The following does not respond when a select field with class='crit' is inserted in to the page via ajax once the page has loaded, and is then changed. How can I make it do so?

$(".crit").click(function(){alert("hello")}) 
0

1 Answer 1

7

Use this:

$('.crit').live('click', function(e) { alert('hello'); }); 

A regular event is only bound to the currently existing elements. When using live() the event handler is bound to the document itself and thanks to event bubbling it doesn't no handlers have to be attached to the actual elements.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.