admin管理员组文章数量:1332969
I'm attempting to set CSS styles on a certain class within a custom Angular directive when it is clicked. I want to acplish this (and any other DOM manipulation) within the Link function.
Below is what I have so far, but I'm getting an address.on is not a function
error. How would I properly set the CSS -webkit-filter: none
on the blur
class when blur
class elements are clicked?
function link(scope, element, attributes) {
var address = element[0].getElementsByClassName('blur');
address.on('click', function() {
address.css({'-webkit-filter': 'none'});
});
}
I'm attempting to set CSS styles on a certain class within a custom Angular directive when it is clicked. I want to acplish this (and any other DOM manipulation) within the Link function.
Below is what I have so far, but I'm getting an address.on is not a function
error. How would I properly set the CSS -webkit-filter: none
on the blur
class when blur
class elements are clicked?
function link(scope, element, attributes) {
var address = element[0].getElementsByClassName('blur');
address.on('click', function() {
address.css({'-webkit-filter': 'none'});
});
}
Share
Improve this question
asked Jun 30, 2015 at 15:09
MattDionisMattDionis
3,61610 gold badges55 silver badges110 bronze badges
1 Answer
Reset to default 9address
is a DOM element. You need to wrap it in angular.element
to turn it into a jqLite object:
function link(scope, element, attributes) {
var address = angular.element(element[0].getElementsByClassName('blur'));
address.on('click', function() {
address.css({'-webkit-filter': 'none'});
});
}
本文标签: javascriptHow to set CSS styles within Link function of Angular directiveStack Overflow
版权声明:本文标题:javascript - How to set CSS styles within Link function of Angular directive - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742345362a2457411.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论