简体   繁体   English

AngularJS:删除Aria属性

[英]AngularJS: Removing Aria attribute

I'm using AngularJS datepicker plugin. 我正在使用AngularJS datepicker插件。 It is adding aria-required=false attribute dynamically to datepicker md-content . 它将aria-required=false属性动态添加到datepicker md-content I want to remove that attribute. 我想删除该属性。 As it is coming dynamically through Angular, I cannot do it through HTML, so I want JS code to remove that. 因为它是通过Angular动态传递的,所以我不能通过HTML来实现它,所以我想要JS代码来删除它。

I've tried couple of approaches, but none of them seem to work. 我尝试了几种方法,但它们似乎都没有用。 Just to mention one approach, which didn't work: 只提一种方法,它不起作用:

$('.datepicker-class').removeAttr('aria-required');

There are no console errors, but still it didn't remove the attribute. 没有控制台错误,但仍然没有删除该属性。

Any solution to remove this attribute through JS? 任何通过JS删除此属性的解决方案?

Try 尝试

angular.element(document).ready(function(){
angular.element('.datepicker-class').removeAttr('aria-required')
})

JQuery doesn't always play well with angular as they exists within different execution contexts, but you can use the angular.element function which will use JQlite (enough for what you're doing) or JQuery if you're using that. JQuery并不总能很好地使用angular,因为它们存在于不同的执行上下文中,但你可以使用angular.element函数,它将使用JQlite(足够你正在做的事情)或JQuery(如果你正在使用它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM