Hello, when I click on one of the 3 options in "HTML" that is in the code below, I want the function in "JS" to issue an "alert" with the "idPost" in which it was clicked. EX: When I click on the link "PHP" it issues an alert 25, which would be its idPost. But when I click on the other options the function does not emit any alerts. If I did other two functions and changed the ids, I know it would work, but since it is a post system, that would be my options, when adding a new post I would have to do another new function, so I used the same ids. I hope it has been made clear!
HTML code:
<p id="linkPost" idPost="25"><a href="#">PHP</a></p>
<p id="linkPost" idPost="26"><a href="#">HTML</a></p>
<p id="linkPost" idPost="27"><a href="#">JAVASCRIPT</a></p>
JS Code:
$('#linkPost').on('click', function(){
var id = $(this).attr('idPost');
alert(id);
});