-1

I have code in html like

<div id="edit" ng-click="editFunction($event)">
  <span id="1">
    click1
  </span>
  <span id="2">
    click2
  </span>
  <span id="3">
    click3
  </span>
  <span id="4">
    click4
  </span>
  ....
</div>

in controller.js

myDIV.controller('control',function($scope){
 $scope.editFunction($event){
   alert($event.target.id);
}

});

When user clicks in the div tag he should click on any of the span tags. Using the code we are able to get the div id. But actually I need to know which span is clicked. Means id="1" or 2 or 3 ... Thank you.

1 Answers1

0

you can use clickevent, this might work:

    <div id="edit" ng-click="editFunction($event)">
  <span id="1" class="click">
    click1
  </span>
  <span id="2" class="click">
    click2
  </span>
  <span id="3" class="click">
    click3
  </span>
  <span id="4" class="click">
    click4
  </span>
  ....
</div>

    $('.click').on('click', function(event) {
    alert($(event.target).attr('id'));
    });
Shivin Agarwal
  • 158
  • 2
  • 16