I have the following code which work fine:
$('.ui-selectmenu-menu a').click(function() { alert('OK'); });
However, if I replace it with:
$('.ui-selectmenu-menu a').live('click', function() { alert('OK'); });
it does not work.
What could be the reason for that ?
(In my case, $('.ui-selectmenu-menu a') elements could be removed and added again during the run.)
If the class changes e.g. the parent doesn’t have
class="ui-selectmenu-menuthen the selector would no longer match, make sure this isn’t happening after whatever events you have.Unlike binding directly to the element, the selector no longer matching will stop a
.live()handler from firing for that element’s events.