I need to add a jquery listener to some dynamically created elements. I cannot for the life of me to get this to work. tag_options is not dynamic, its children are. I have tried three ways:
<div id = "tag_options">
<div class = "tag_option">hover me</div>
</div>
The js:
// never works
$('#tag_options').delegate('.tag_option', 'hover', function(event){
alert();
});
// never works
$("#tag_options").on("hover", "[class='tag_option']", function(event) {
alert();
});
// works if not dynamically created
$('#tag_options .tag_option').hover( function(){
alert();
});