Skip to content
Advertisement

How to delete value in class in php (wordpress)?

I need to remove ‘wsqmylogin’ which is inside class with if condition.
I tried all the folloing codes but it doesn’t remove ‘wsqmylogin’.
Would you please let me know how to delete it?

Existing Code:

<div class="elementor-column">
     <div class="elementor-column elementor-element-84c7af1 wsqmylogin" data-id="84c7af1" 
     data-element_type="column" id="my-checkout">
     </div>
</div>


Codes I tried:

<?php
$removeMyLoginJs = <<<EOD
<script>
    function myFunction() { 
        var element = document.querySelectorAll(".elementor-column");
        element.classList.remove("wsqmylogin");
     }
</script>
EOD;

$currentSlug = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];  
if(strpos($currentSlug,'order-pay') !== false){
    echo $removeMyLoginJs;
}

<?php
$removeMyLoginJs = <<<EOD
<script>
    function myFunction() { 
var myTbl = document.getElementsByClassName("elementor-row")[0];
var tSomeStyleClasses = myTbl.getElementsByClassName("wsqmylogin");
while (tSomeStyleClasses.length) {
tSomeStyleClasses[0].classList.remove("wsqmylogin");
     }
</script>
EOD;

$currentSlug = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];  
if(strpos($currentSlug,'order-pay') !== false){
    echo $removeMyLoginJs;
}

<?php
$removeMyLoginJs = <<<EOD
<script>
    (function myFunction() { 
        var element = document.getElementById("my-checkout");
        element.classList.remove("wsqmylogin");
     })();
</script>
EOD;

$currentSlug = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];  
if(strpos($currentSlug,'order-pay') !== false){
    echo $removeMyLoginJs;
}

Advertisement

Answer

if you have access to the source code, you can try to delete that from the html/js file itself 😉

OOOOr if you really want to just delete it runtime, try to use element.parentNode.remove

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement