JSFiddle - React, Tailwind, and code Playground
HTML
<div id="announcment-wrap">
<div id="1" class="announcement-text">
This is again a dummy
<a href="http://www.google.com">| click here</a>
<a id="close" href="#" class="close">X</a>
</div>
<div id="2" class="announcement-text">
This is demo 3
<a href="http://www.google.co.in">| Demo3</a>
<a id="close" href="#" class="close">X</a>
</div>
<div id="3" class="announcement-text">
This is demo 4
<a href="http://facebook.com">| Demo again</a>
<a id="close" href="#" class="close">X</a>
</div>
</div>
JavaScript
$(document).ready(function($) {
$('.close').click(function() {
$(this).closest('.announcement-text').hide();
alert($(this).closest('.announcement-text').attr('id'));
});
});