Here is my HTML(below). I just want to remove the angular classes: ng-untouched ng-valid
from the HTML page through a script. I have written simple JavaScript code below that I thought would achieve this. But when I run the script, I still the Angular classes on my page. I am not sure what I could be missing or is there a different method to this? I tried to follow what they have mentioned here: Removing multiple classes (jQuery).
<div class=“mainClass”>
<form action="https://www.google.com/" >
</form>
</div>
JavaScript
$("mainClass, form").removeClass(".ng-untouched .ng-valid");
CodePudding user response:
I think you aren't selecting the class correctly - so try adding the period to the element selector and remove the periods from the class names you're trying to drop.
$("form", .mainClass).removeClass("ng-untouched ng-valid");
note the addition of the period before mainClass and the removal of the periods before each "ng"
CodePudding user response:
Two issues with your code:
- The arguments to
removeClass
should have only the class name, not the selector, ieng-untouched ng-valid
. - Your double quotes are the wrong character for
mainClass
CodePudding user response:
get rid of the dots in front of your classnames.
$(".mainClass, form").removeClass("ng-untouched ng-valid");
CodePudding user response:
$(".mainClass > form").removeClass("ng-untouched ng-valid");