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

112
Visualizações
Compare URL with string and path and insert link text

It is a post template that should work for different posts and in different languages. There should be no different templates for different languages. That's why I thought of the following. I compare the loaded url with string and path. If the condition is met, a URL and text will be added to the following link. Since I'm still at the beginning, I'm interested in your feedback and other approaches. Maybe you have any comments. So I can see what I can do better. Please help me so I can learn more. Thank you

var url = window.location.href
var path = window.location.pathname
var output1 = "http://localhost";
var output2 = output1 + path;

$(window).on('load', function () {
  if (url == output1 + path) {
    $("a.blog-wort").attr("href", "http://localhost/landing1/");
    $('a.blog-wort').text('text 1');
  } else if (url == output2) {
    $("a.blog-wort").attr("href", "http://localhost/en/landing2/");
    $('a.blog-wort').text('text 2');
  } else if (url == output2) {
    $("a.blog-wort").attr("href", "");
    $('a.blog-wort').text('text 3');
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a class="blog-wort"></a>

about 4 years ago · Juan Pablo Isaza
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