Although angular.element is very close to jQuery, it is still not possible to obtain elements directly through HTML tags. The simplest way is as follows:
You can see it by looking at the document
The parameter requirement of angular.element() is HTML string or DOMElement, but what you write is a selector, which does not meet the parameter requirement of angular.element. If you want to use this usage, you need to add jquery
Angular does not recommend direct manipulation of the DOM, so if you want to add class, it is recommended to do so (I can't open your connection, I don't know how you wrote the code, so I will use my own)
Yes, I originally thought about passing the currently clicked button object through ng-click, but in the end I found that Angular does not allow this. . . I had no choice but to use angular’s built-in jQlite to handle it!
Although angular.element is very close to jQuery, it is still not possible to obtain elements directly through HTML tags. The simplest way is as follows:
http://jsfiddle.net/sy38y/2/
You can see it by looking at the document
The parameter requirement of angular.element() is HTML string or DOMElement, but what you write is a selector, which does not meet the parameter requirement of angular.element. If you want to use this usage, you need to add jquery
Change it to this:
Angular does not recommend direct manipulation of the DOM, so if you want to add class, it is recommended to do so (I can't open your connection, I don't know how you wrote the code, so I will use my own)
HTML
js
Yes, I originally thought about passing the currently clicked button object through ng-click, but in the end I found that Angular does not allow this. . .
I had no choice but to use angular’s built-in jQlite to handle it!