1

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

0

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

$(selector).attr(attribute,value)
1
0

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

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

Your Answer

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

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