Ich versuche ID des angeklickten Elements in angularjs zu erhalten, und es funktioniert ganz gut. Unten ist mein CodeAngularjs Problem beim Abrufen der ID des angeklickten Elements
html
<a href="#faqinner/contactform" class="clearfix" ng-click="getCateId($event)" id="{{option.id}}">
<span class="icon">
<img ng-if="option.icon!=null" ng-src="http://images.crownit.in/others/{{option.icon}}">
<img ng-if="option.icon==null" ng-src="https://crownit.in/wp-content/themes/crownit-theme/images/faq_default_icon.png">
</span>
<span class="faq_name">{{option.name}}</span>
<span class="arrow">
<img src="images/right_arrow.png">
</span>
</a>
Controller
$scope.getCateId = function(obj, $event){
$rootScope.cateId = obj.target.id;
console.log($rootScope.cateId);
};
Der obige Code die ID des angeklickten <a>
Tag zurückgeben sollte, aber das Problem ich dort bin vor ist ist mehr <span>
in <a>
Tag so, wenn ich auf t Er Raum von span es Ziel ist der <span>
Tag, der keine ID hat, aber wenn ich speziell auf den oberen freien Raum, wo keine innere <span>
abgedeckt klicken dann funktioniert es gut.
Wie bekomme ich die ID <a>
auch wenn ich auf <span>
space klicke ??