You can refer to an element by id:
$('#person__1_badge_number').addClass('make_it_red');
In addition, it depends on how you dynamically inserted the element, if you just added it as a string to some div, for example, it cannot be bound to the DOM.
EDIT: you can get the identifier of the element from the binding and build a selector in the callback:
function please_rebind() { $('.number').bind("change", function() { var elementId = this.id; $.post('/registration/sell/check_badge_number', { number: $(this).val() }, function(data) { $('#' + elementId).addClass('make_it_red'); alert(data); }, "html"); }); }
source share