If I have the following div
<div class = "someclass">
1234
</div>
and a simple html button on my site. When the user clicks on the button I want to execute a function that will take the content from that div with the class "someclass" (in other words 1234) and append to it to the URL e.g. https://www.externalsite.com/parameter=(contents from the div) and open that url in another tab. So the final URL comes in as https://www.externalsite.com/parameter=1234. Everything before parameter in the URL always stays the same. Thanks in advance
You can use HTMLElement.innerHTML:
let url="https://www.externalsite.com/parameter=" // definie url first part
let btn=document.getElementById('click') // get the button element
btn.addEventListener('click',function() {url+=document.getElementById('someid').innerHTML})
open(url)
<div id = "someid"> <!--the id will be unique, but more element can have the same class attribute-->
1234
</div>
<button id="click"></button>