Skip to main content
1-Visitor
May 27, 2020
Solved

Change CSS class of a button

  • May 27, 2020
  • 2 replies
  • 1896 views

I'm trying to create a function which removes the class of a button and then adds another class:

$scope.tutorialShow = function () {
 angular.element(document.querySelector("[widget-id=instructionInfoButton] button")).removeClass("test").addClass("button");
}

 

I'm not sure the error in my code.

Best answer by WilsonT

Hi Micah,

 

Can you try the following?

$scope.tutorialShow = function () { 
 $scope.setWidgetProp('instructionInfoButton','class',undefined);
 $scope.setWidgetProp('instructionInfoButton','class','button');
}

 

 

2 replies

WilsonT14-AlexandriteAnswer
14-Alexandrite
May 28, 2020

Hi Micah,

 

Can you try the following?

$scope.tutorialShow = function () { 
 $scope.setWidgetProp('instructionInfoButton','class',undefined);
 $scope.setWidgetProp('instructionInfoButton','class','button');
}

 

 

12-Amethyst
May 28, 2020

I believe the quotes around the widget id are not correct in your code.  Here is an example from an experience I've created:

 

angular.element(document.querySelector('[widget-id="PartIDListGrid"] .row:nth-child(2)')).addClass("SelectedItem");

 

I think yours should be (I didn't test):

 

angular.element(document.querySelector('[widget-id="instructionInfoButton"] button')).removeClass("test").addClass("button");