I want to add the click event to all elements where the `id="violacao":
$(document).ready(function () {
jQuery('#violacao').click(function() {
alert('teste');
});
});
But just the first link responds to the click. This is the HTML generated:
<tr>
<td><a href="#" id="violacao">40954589</a></td>
<td>Perda de Comunicação</td>
</tr>
<tr>
<td><a href="#" id="violacao">88692020503</a></td>
<td>Perda de Comunicação</td>
</tr>
When I try this way:
jQuery("a").click(function() {
alert('teste');
});
It works fine, except that all links are affected. What is wrong?