I have some Javascript that I want to use to reference parts of a URL. I'm trying to insert the query string onto a page using HTML but i'm not sure how. Here is the javascript code:
const urlParams = new URLSearchParams(window.location.search);
const ref = urlParams.get('ref')
span = document.getElementById('refName');
txt = document.createTextNode(ref);
span.appendChild(txt);
<span id = 'refName'></span>
I want to be able to display parts of the URL using HTML. Thanks!