Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Append text from field to a URL and open the URL in a new tab

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

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda