We can get class list by using JavaScript element. Here we can get JavaScript Element from angular element with $event.target. In this example, we are going find out the classes of button element which triggers click event.

Markup

<button class="btn btn1 btn2" ng-click="getClassList($event)">
  Get Class List
</button>

Script

$scope.getClassList = function($event) {
      var classList = $event.target.className.split(/\s+/);
      alert(classList);
      for (var i = 0; i < classList.length; i++) {
        if (classList[i] === 'someClass') {
          //do something
        }
      }
}

1 comment:

  1. I love it here. Keep sharing your good vibes. I love them Are you also searching for dissertation writing help? we are the best solution for you. We are best known for delivering cheap assignments to students without having to break the bank

    ReplyDelete

Blogroll

Popular Posts