<div id="news">
<?php if ($result = $link->query("SELECT * FROM news")) {
$row = $result->fetch_all();
$i = 0;
foreach ($row as &$value){
$i++;
echo('<div id="new" class="'.$i.'"=> <img src="'.$value[1].'"><div id="new-cent">'.$value[2].'</div><div id="new-text">'.$value[3].'</div></div>');
}
}
$result->close(); ?>
<script>
$('#new').click(function () {
alert($('#new').attr('class'));
});
</script>
</div>
$('html').on('click','.new',function () {
//code
});