Is it possible to replace class name value attribute in layout?

for example body has 3 classes x y z I want it to be c y z

how to replace class x to c

I can add class c using <attribute name="class" value="c"/>

the result is body has 4 classes c x y z how to remove the x class ?

2 Answers 2


Go to the template, then you handle this with basic javascript. Make an ajax call to get the class you need and then replace the value by modifying dom.With jquery


Add the below jquery in custom js which is working on page load.

$(document).ready(function() {
  • In my case I would only remove class since the other class already added through layout right? Commented Jul 29, 2022 at 8:13
  • @MahmoudM.Abdelmalek check the updated answer.it will just remove the class. Commented Jul 29, 2022 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.