I have a directive:
class LkfsSliderDirective {
constructor() {
this.restrict = "E";
this.templateUrl = "./controls/lkfsSlider/lkfsSliderTemplate.html";
this.controller = 'LkfsSliderController';
this.controllerAs = 'slider';
this.replace = true;
}
link(scope, element, attrs) {
}
}
export default LkfsSliderDirective;
In HTML:
<img ng-src="{{slide.image}}" class="lkfs-slider-slide" alt="" id="{{slide.id}}" ng-repeat="slide in slider.slides"/>
I would like get img
tag by class name with specific id (for example = 0) and set CSS ( display: block
).
I tried in many ways but nothing works, for example:
var elem = document.getElementsByTagName("img")[0];
angular.element(elem).css('display', 'block');
Also in link.
Any ideas?
Just select the element with the specific ID using document.getElementById()
:
var elem = document.getElementById("0");
angular.element(elem).css('display', 'block');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.