-1

I want to remove a attribute in all the elements of the DOM. For example:

<div id="someId">
   <div ng-model="aaa"></div>
   <p ng-model="bbb"></p>
   <span ng-model="ccc"></span>
</div>

I want to remove the ng-model attribute from all the elements which are inside the div with id as someId. Is there any way to do this using jquery.

Gaurav
  • 872
  • 12
  • 28
  • What do you achieve? – Stepan Kasyanenko Mar 04 '16 at 10:27
  • Mixing Angular with jQuery like this is gonna trouble you... – Rayon Mar 04 '16 at 10:28
  • $('*').removeAttr('ng-model') - for removing the attribute from all elements in DOM – Kira Mar 04 '16 at 10:30
  • 2
    Removing an AngularJS attribute from an element won't remove the directive or its controller. The element needs to be destroyed and re-compiled with the `$compile` service. There is no simple way to do it with jQuery. Don't even try. Instead read this [“Thinking in AngularJS” if I have a jQuery background?](http://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background) – georgeawg Mar 04 '16 at 11:19

2 Answers2

1

Try like following using removeAttr().

$('#someId [ng-model]').removeAttr('ng-model')
Ibrahim Khan
  • 20,616
  • 7
  • 42
  • 55
0

use function removeAttr()

try this

$("#someId").removeAttr("ng-model");