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

169
Visualizações
How to add an anchor <a> tag / html to a Swal call

I am trying to add an anchor tag to my swal tag (I am using Sweetalert with cdn). Is there any way to do this specifically with jQuery (not Angular/React)?

I have tried using a variable with the value of the link as below:

swal({
text: "foo",
content: "link" + (backtick)<a href="link">Link</a>(backtick)
});

But why this did not work?

Thanks.

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

0

As @Louys pointed out in the comment above, use SweetAlert2 (the latest)

<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

Then you can utilise the html field, like so:

Swal.fire({
  title: '<strong>HTML <u>example</u></strong>',
  icon: 'info',
  html:
    'You can use <b>bold text</b>, ' +
    '<a href="//sweetalert2.github.io">links</a> ' +
    'and other HTML tags'
})

Using a 'template literal' - backticks (`) - you can insert variables and add a link like so:

var my_link = 'http://google.com';
Swal.fire({
  title: '<strong>HTML <u>example</u></strong>',
  icon: 'info',
  html: `<a href="${my_link}">Click here!</a>`
})
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