jQuery get attr

jQuery get attr

Hi. I am trying to get attr 'data-id of specific button since few hours and I can not manage to do it. please help

  1. <div class="row" id="answersRow"> 
  2. <div class="col-xs-12" id="answers">
  3. <button  data-id="{{answer.id}}" ng-repeat = "answer in post.answers track by $index"             class="btn btn-success answer" ng-click="addVote()">{{answer.text}}</button>
  4. </div>
  5. </div>
My approach:

  1. $('.answer').click(function(){
  2.       $(this).attr('data-id');
  3. })