简体   繁体   中英

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;
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM