Your code is fine you have same id for more then one element which is not valid. The event will be binded to first element with given id in the DOM
. Use common class instead of id to bind the event. You can use class selector to bind the event.
Live Demo
$('.btn').click(function() {
var d = $(this).data('datac');
alert(d);
});