I am generating some twitter bootstrap alert messages and i want to remove the ones i have read and only be left with the ones i like to investigate further.
This how i generating them
$a = $this->session->userdata('identity');
$ar = trim($a,",");
$arr = explode(',', $a);
foreach($arr as $key => $value){
echo '<div class="cb alert alert-warning"><a href="#" class="close" data-dismiss="alert" data-array-key="'.$key.'">×</a><strong>Warning!</strong> '.$value.' </div>' .'<br/>';
}
This is my jquery code
(function ($) {
$( ".close" ).on('click', function() {
alert('close clicked');
});
})(jQuery);
I know my code works because it works on jsfiddle http://jsfiddle.net/15oar2gr/
Why is my code not working for dynamically generated content?.