'How to add class name to an existing tag in php
I have a hidden tag in html code:
<p class="class1">something<p>
and php code:
if(SomeCondition){
select element by DOM and add class "active" so that element will be shown
}
how can I select element by DOM specifically in this php file and perform operations on an element, for example add class or remove class or change its properties (f.e.: bg color: black). Thank you.
P.S. SomeCondition is server-sided
Solution 1:[1]
You don't do it in PHP that way. I mean not in a simple way. This is done in JS / jQuery, e.g.
$(document).ready(function(){
$(".class1").addClass("active");
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | newbie.user88 |