Uzair
Uzair

Reputation: 21

How to remove text that is not under any element with JavaScript

There are some codes loading at the footer of my website. when I viewed source code it doesn't have any element and I am not able find them inside my WordPress theme files. How can I remove them?

When I inspect it, it is just showing like this (without any element).

body.single-product .layout-sidebar-no div.product div.summary {
width: 48%;
}
body.single-product .layout-sidebar-no div.product div.images {
width: 50%;
}

Upvotes: 2

Views: 398

Answers (2)

mmendescortes
mmendescortes

Reputation: 129

Replace the content on the rendered HTML with an empty string

If it is inside the body tag of your HTML, all tou need to do is replace it with an empty string.

For example:

window.onload=()=>{
    document.body.innerHTML.replace("pure-text", "");
}

What I did was basically get everything from the body tag and replace the string "pure-text" with an empty string.

Please, note the window.onload that ensures the code runs after everything is loaded.

This exemple however can fail easily on situations where the thing you want to remove loads dinamically with a new name after every request, be aware of that.

Upvotes: 1

Leandro Luque
Leandro Luque

Reputation: 538

Use the String Locator plugin. Search for it and remove. If it is not dynamically generated, you'll find it.

Upvotes: 0

Related Questions