I'm trying to create a script to replace everything inside a div with something predefined, I'm new to javascript and I'm having trouble finding a solution for this, I've looked in various places, but I have not achieved anything.
I am calling the script using url.searchParams.get
if(url.searchParams.get("sub") == 1) {
document.getElementById("rep").innerHTML = "<p>Outro texto</p>"
}
<div id="rep">Texto</div>