Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Cómo agregar una etiqueta ancla <a> / html a una llamada Swal

Estoy tratando de agregar una etiqueta de anclaje a mi etiqueta swal (estoy usando Sweetalert con cdn). ¿Hay alguna forma de hacer esto específicamente con jQuery ( no Angular/React )?

He intentado usar una variable con el valor del enlace como se muestra a continuación:

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

Pero, ¿por qué esto no funcionó?

Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como @Louys señaló en el comentario anterior, use SweetAlert2 (el último)

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

Luego puede utilizar el campo html , así:

 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' })

Usando una 'plantilla literal' - comillas invertidas (`) - puede insertar variables y agregar un enlace así:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!